JSON: Difference between revisions

73 bytes added ,  13 August 2019
m
Corrections
m (name/value pairs link)
m (Corrections)
Line 15: Line 15:
The pairs are separated from each other with commas: <font color="blue">"name1":''value1'', "name2":''value2'', "name3":''value3''...</font> (the last pair in such a series should <u>not</u> be followed by a comma however).
The pairs are separated from each other with commas: <font color="blue">"name1":''value1'', "name2":''value2'', "name3":''value3''...</font> (the last pair in such a series should <u>not</u> be followed by a comma however).


Special character may be "escaped" in string values (or indeed names) with a backslash: <font color="blue">'''\'''</font>
Special characters may be "escaped" in string values (or indeed names) with a backslash: <font color="blue">'''\'''</font>
*'''\\''' represents '''<font color="blue">\'''</font> (backslash)
*'''\\''' represents '''<font color="blue">\'''</font> (backslash)
*'''\/''' represents '''<font color="blue">/'''</font> (forward slash)
*'''\/''' represents '''<font color="blue">/'''</font> (forward slash)
Line 78: Line 78:
When migrating data from JSON to a struct sometimes a member might be missing from the JSON data. For example because the element you are looking for is empty. In that case the runtime will trigger a runtime error. You can disable that by setting the [https://docs.dataaccess.com/dataflexhelp/mergedProjects/VDFClassRef/cJsonObject-Property-pbRequireAllMembers.htm pbRequireAllMembers] property of the DataFlex Json object to false.
When migrating data from JSON to a struct sometimes a member might be missing from the JSON data. For example because the element you are looking for is empty. In that case the runtime will trigger a runtime error. You can disable that by setting the [https://docs.dataaccess.com/dataflexhelp/mergedProjects/VDFClassRef/cJsonObject-Property-pbRequireAllMembers.htm pbRequireAllMembers] property of the DataFlex Json object to false.


If you need to deal with JSON which uses DataFlex reserved words (or other invalid values) in its member names then, since DataFlex 19.1, you can now use a valid name in your struct and assign a different name for the conversion via meta-data tags. This is sometimes referred to as the [https://docs.dataaccess.com/dataflexhelp/mergedProjects/Tools/Name_Meta-Data_Tag.htm altName member]
If you need to deal with JSON which uses DataFlex reserved words in its member names (or other invalid values, such as those containing spaces in the example above: e.g "first name") then, since DataFlex 19.1, you can now use a valid name in your struct and assign a different name for the conversion via meta-data tags. This is sometimes referred to as the [https://docs.dataaccess.com/dataflexhelp/mergedProjects/Tools/Name_Meta-Data_Tag.htm altName member]


== External references ==
== External references ==