I need to go through JSON records and, in each case, find a particular member and then extract that (and all its subs) as a string. I can find it easily enough, but extracting it is another matter. Is there any easy way to do this?
c34.s = Chr(34)
jsonString.s = "{"+c34+"blob"+c34+":{"+c34+"mimeType"+c34+":"+c34+"image/jpeg"+c34+","+c34+"$type"+c34+":"+c34+"blob"+c34+","+c34+"size"+c34+":11689,"+c34+"ref"+c34+":{"+c34+"$link"+c34+":"+c34+"bafkreih44nkqvldurfdvtnctr3m7a3wmn7ayv2vku3oyhdslzdj3pidarm"+c34+"}}}"
j = ParseJSON(#PB_Any,jsonString)
If j
ObjectValue = JSONValue(j)
If ExamineJSONMembers(ObjectValue)
While NextJSONMember(ObjectValue)
Select JSONMemberKey(ObjectValue)
Case "blob"
value = JSONMemberValue(ObjectValue)
If ExamineJSONMembers(value)
While NextJSONMember(value)
If JSONMemberKey(value) = "ref"
value2 = JSONMemberValue(value)
t.s = ComposeJSON(value2)
Break 2
EndIf
Wend
EndIf
EndSelect
Wend
EndIf
FreeJSON(j)
EndIf
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Yes, it's always the same JSON structure so I can use ExtractJSONStructure(), but I hoped there would be a simpler and more elegant way of doing this. Thanks for your replies.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."