ExtractJSONStructure()

Syntax

ExtractJSONStructure(JSONValue, *Buffer, Structure)
Description
Extract members from the given JSON value of type #PB_JSON_Object into the specified structure memory. The structure will be cleared of any previous content before extracting the JSON values.

Parameters

JSONValue The JSON value. The value must be of type #PB_JSON_Object.
*Buffer The address of the structure memory to fill.
Structure The type of the structure to fill.

Return value

None.

Remarks

The extraction is performed recursively if the structure contains further structures, arrays, lists or maps. If the JSON value contains any members that do not have the proper type to match a structure member they will be ignored and the corresponding structure member is left empty.

Any '*' or '$' characters are stripped from the structure member names before comparing them to the JSON object members. So a member key must not include these characters to be properly matched to a structure member.

The comparison of member keys to structure member names is performed case sensitive.

Example

  Structure Person
    Name$
    Age.l
    List Books.s()
  EndStructure

  Input$ = "{" + Chr(34) + "Name" + Chr(34) + ": " + Chr(34) + "John Smith" + Chr(34) + ", " + 
                 Chr(34) + "Age" + Chr(34) + ": 42, " + 
                 Chr(34) + "Books" + Chr(34) + ": [" +
                           Chr(34) + "Investing For Dummies" + Chr(34) + ", " + 
                           Chr(34) + "A Little Bit of Everything For Dummies" + Chr(34) + "] }"
                           
  ParseJSON(0, Input$)
  ExtractJSONStructure(JSONValue(0), @P.Person, Person)
  
  Debug P\Name$
  Debug P\Age
  Debug ListSize(P\Books())

See Also

ExtractJSONArray(), ExtractJSONList(), ExtractJSONMap(), InsertJSONArray(), InsertJSONList(), InsertJSONMap(), InsertJSONStructure(), SetJSONObject(), JSONType()

Supported OS

All

<- ExtractJSONMap() - Json Index - FreeJSON() ->