[Progress Communities] [Progress OpenEdge ABL] Forum Post: Searching for objects in JSON

Status
Not open for further replies.
N

Neil Treeby

Guest
I have some sample C# code that uses syntax like this to get values out of a JSON entity. If I have JSON like this: { "Object1": { "Array2" [ {"Ref": "someRef", "Value": "someValue"}, {"Ref": "someOtherRef", "Value": "someOtherValue"} ] } } The C# code looks like: var someValue = root.Object1.Array2.First(stuff => stuff.Ref = "someRef").Value; What that gets me is: someValue = "someValue" So far the equivalent in ABL code would be: ostuff = ojson:GetJsonObject("Object1"):GetJsonArray("Array2"). DO viLinkIdx = 1 TO ostuff:LENGTH: CASE ostuff:GetJsonObject(viLinkIdx):GetJsonText("Ref"): WHEN "someRef" THEN ASSIGN vcSomeValue = ostuff:GetJsonObject(viLinkIdx):GetJsonText("Value"). END CASE. END. I wind up with the same result: vcSomeValue = "someValue" Now, am I missing something, or is there an easier way to do this kind of searching in JSON using ABL? Before I start to extend the JsonObject class to do something similar?

Continue reading...
 
Status
Not open for further replies.
Top