Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter EightData Functions (continued)

8.7 JavaScript Object Notation (JSON)

8.7.1 Overview

JavaScript Object Notation (JSON) is an open standard file format, and data interchange format, that uses plain text to store and transmit data objects consisting of attribute-value pairs and/or array data types. It is a very common data format, with a diverse range of applications, such as serving as replacement for XML in AJAX systems.

Legato allows for the loading and reading of JSON Objects. It is a language-independent data format where string content is assumed to be encoded in UTF-8 (or 16 and 24).

JSON data is represented either as objects or arrays. Each of these may contain numeric, string or limited keyword data. Objects and data can be named with an item name. When referencing data, the expected type of data is important to avoid run time errors. The JSONGetType function can be used to get the type of data contained within an item. These canbe any of the following:

  SDK Define   Ordinal   Description  
  JSON_DATA_TYPE_NULL   0   NULL Type (empty)  
  JSON_DATA_TYPE_STRING   1   String Type (UTF-8 encoded)  
  JSON_DATA_TYPE_NUMBER   2   Number Type  
  JSON_DATA_TYPE_OBJECT   3   Object Type  
  JSON_DATA_TYPE_ARRAY   4   Array Type  
  JSON_DATA_TYPE_BOOL   5   Boolean Type  

 

8.7.2 Item Name

Items are accessed by a name in the following syntax:

obj.name[n].name[n]. ...

Where:

  obj An arbitrary string as the the top object node. All objects must be preceded with “obj.” or “obj[n].”
  name Is the name of the node.
  [n] Specifies an optional zero-based item number in a list.

  

The JSONGetArrayCount function can be used on an array node to determine the total number of items in an array.

8.7.3 Access by Direct Index

Once loaded, object can also be accessed by direct index. This allows for examination of both data and key names by using the JSONGetObjectIndex and JSONGetObjectKeyName functions.

8.7.4 Functions

Page revised 2024-12-13