How to read array of data series in json into Igor waves?

I want to read data from a json file into Igor waves. The example file (s. below) contain a series with time stamps and 3 data series. I want to end the time stamps and the 3 data series each in an Igor wave. Optimally I could get the names for the waves from the json file ("unix times", "data 1", "data 2", "data 3").  

I can manage to parse the json file and to extract the series of time stamps.

Function dada()

    Variable jsonId
   
    JSONXOP_Parse(FetchURL("file:///Users/eckart/Desktop/response_shortened.txt"))
    jsonId = V_value
   
    JSONXOP_Dump jsonId
    print S_Value

    JSONXOP_GetArraySize jsonId, "/unix_seconds"
    print "Array size of unix_seconds :", V_value
   
    JSONXOP_GetArraySize jsonId, "/production_types"
    print "Array size of production_types:", V_value

    JSONXOP_GetValue/WAVE=tStamps jsonId, "/unix_seconds"
   
    JSONXOP_Release jsonId

end

But I am lost when it comes to extracting the 3 data series. I suspect I have to loop over the array in production_types, but cannot figure out the syntax.

 

Can someone please help?

Example json (6.28 KB)

it is really not that difficult

Function dada()

    Variable k, jsonId, nProdTypes
    String str
   
    JSONXOP_Parse(FetchURL("file:///Users/eckart/Desktop/response_shortened.txt"))
    jsonId = V_value
   
    JSONXOP_Dump jsonId
    print S_Value

    JSONXOP_GetArraySize jsonId, "/unix_seconds"
    print "Array size of unix_seconds :", V_value
   
    JSONXOP_GetValue/WAVE=tStamps jsonId, "/unix_seconds"
   
    JSONXOP_GetArraySize jsonId, "/production_types"
    nProdTypes = V_value
    print "Array size of production_types:", nProdTypes
   
    k = 0  
    do
        sprintf str, "/production_types/%d/name", k
        JSONXOP_GetValue/T jsonId, str
        sprintf str, "/production_types/%d/data", k
        JSONXOP_GetValue/WAVE=$S_value jsonId, str
   
        k += 1
    while (k < nProdTypes)

    JSONXOP_Release jsonId

end

I hope someone will profit from me asking and answering.

Yes that looks correct. I personally prefer the JSON wrapper functions instead of the operations but that is more a taste thing. Depending on the size of the json file one could move the code in the do/while loop into a function and call that via wave indexing, Multithread does unfortunately not help as the JSON XOP does not allow concurrent read access.