To continue with this content, please log in with your Data Access ID or create a new account.
Cancel Data Access ID
You may not be authorized to see this content. Please contact Data Access Europe for more information.
Cancel Data Access Europe
You are not authorized to see this content.
Cancel Data Access Europe
Next lesson:
Parsing JSON
Cancel

Working with JSON

Lesson 1: What is JSON?

What is JSON?

  • JSON stands for JavaScript Object Notation.
  • It is a lightweight data-interchange format that is a textual representation of data that is usually in memory. It is native to JavaScript and should be recognizable to C-style programmers. It is very human-readable, and machines can easily parse and generate it.               
  • JSON is used to serialize data from memory to store it or to send it to a different application. In other words, to interchange data. Its format is common and recognizable to programmers, in that it has nested objects and arrays.
  • The JSON object is a set of name value pairs. Values are wrapped in curly brackets {}, are comma separated, and can be strings, numbers, arrays or Booleans. Values can also be nested.

Comparing JSON to XML

  • JSON is a bit lighter to read
  • There are no open/close tags in JSON
    • The name of every element is listed just once in JSON
  • JSON supports arrays that XML does not
  • Both are human readable
  • Both are hierarchical (nested objects)
  • XML is more extensive, standardized and supported
  • JSON is quicker and less standardized
  • JSON is easier to parse
  • JSON is native to JavaScript

There are three ways to use JSON in DataFlex:

  1. cJsonObject
    • Manually parses and generates JSON
    • Will serialize or deserialize structs and arrays into JSON
  2. cJsonHttpTransfer
    • To communicate JSON over HTTP
  3. Web Services support
    • Have built in JSON support
    • Every web service made in DataFlex can be called using SOAP and XML, but the same service can also be called using JSON.
      • This is not Restful JSON services