This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Have you been able to solve this? If not I've got some code that might help - I've contrived a web service to return your sample JSON and have a basic parser which picks out data from each part.
#JsonRandomAccessReader.SetSourceHttpResponse Httpresponse(#HttpRequest.Response) Errorinfo(#JsonErrorInfo)
If Cond(#JsonErrorInfo.OK)
#FXRETCD := 'NR' /* Set to no parts found right here */
For Each(#Part) In(#JsonRandomAccessReader.ReadObjectWithName( "parts" ))
#FXRETCD := 'OK'
If Cond(#Part.isObject)
#RootObject.ParseString String(#Part.asString) Errorinfo(#JsonErrorInfo)
If Cond(#JsonErrorInfo.OK)
#LW3ITEMCD := #RootObject.GetString( 'part_number' ).AsNativeString.Trim
#QSRKEY := #LW3ITEMCD.Trim.Reverse.Substring( 1 4 ).Reverse
Add_Entry To_List(#LS_PARTS)
Endif
Endif
Endfor
Endif
Maybe your example is better? If so, could you share it? (Currently stuck again with another JSON response that has a different format).
No problem - so on the server I run the API to return your JSON. The first step after that (after testing HTTP response codes etc) is to load that response into a JSON Document;
Then I use a FOR loop to read through the JSON document, looking for the PARTS structure. Once I've found that, another FOR loop processes that inner structure grabbing (in this case) the id and part_number and writes a record to my working list #PartsList.