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?
I was able to successfully extend both JsonArray and JsonObject (and have r-code to prove it), but the reason a helper class is needed is because I can't cast up from JsonConstruct, JsonArray or JsonObject to my new class in order to access my methods.
The tendency is to move away from inheritance anyway for all sorts of reasons, so a helper class is a wise decision.
The problem is not so much with the JSON class being in need of upgrade, but more the whole support for arrays in the ABL. If you look in languages like JS, it strikes me that they have such fancy methods to search and filter their arrays.