JSON: Difference between revisions

From DataFlex Wiki
Jump to navigationJump to search
(Adding a page for JSON)
 
m (Adding categories)
Line 14: Line 14:


If you have a struct that uses reserved words then since DataFlex 19.1 you can now use a non reserved name 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 have a struct that uses reserved words then since DataFlex 19.1 you can now use a non reserved name 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]




Line 23: Line 21:


* [http://jsonlint.com JSONLint the json validator]
* [http://jsonlint.com JSONLint the json validator]
[[Category:REST]]
[[Category:JSON]]
[[Category:System Integration]]

Revision as of 11:58, 13 August 2019

JSON stands for JavaScript Object Notation and is a format used for data exchange that has some similarities to XML.

It is a format that is often used in RESTful webservices and as such it is important to be able to use it from within DataFlex.

Before DataFlex 19.0 you had to resort to external libraries in order to use JSON, see for example JSON Parsing ... the beginnings of an alternative approach

As of DataFlex 19.0 we have native support for JSON objects and can access and directly work with these data structures. This functionality is offered via the cJsonObject

One of the great features in that class is that you can move all your data from JSON into a struct with just one command and vice versa. In order to transfer your data from JSON to a struct you would use the JsonToDataType function and if you have to convert data from a struct to JSON then you can use DataTypeToJson.

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 pbRequireAllMembers property of the DataFlex Json object to false.

If you have a struct that uses reserved words then since DataFlex 19.1 you can now use a non reserved name and assign a different name for the conversion via meta-data tags. This is sometimes referred to as the altName member


External references