Encoding and Decoding JSON Content

    Expressor includes a datascript module that provides for encoding and decoding of JSON (JavaScript Object Notation) content.  Your Expressor Datascript coding can use this functionality in two ways:


    1. To read or write JSON content.
    2. To pass Datascript tables between operators as a string type.


    To use this module, include the appropriate require statement in your code.


    require 'json'


    To convert a Datascript table into a JSON content (which is a string), use the json.encode function and to convert JSON content into a Datascript table, use the json.decode function. 


    A Datascript table encoded into JSON content may use numeric, string or a combination of numeric and string indexes.  Unless you are certain that the Datascript table produced from JSON content will use only numeric indexes, use the pairs function to iterate through the table.