GoFiler Legato Script Reference
Legato v 1.5d Application v 5.25a
|
Table of Contents | < < Previous | Next >> |
Chapter Eight — Data Functions (continued)
8.7 JavaScript Object Notation (JSON)
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 |
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.
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.
Page revised 2024-12-13
Table of Contents | < < Previous | Next >> |
© 2012-2024 Novaworks, LLC. All rights reserved worldwide. Unauthorized use, duplication or transmission prohibited by law. Portions of the software are protected by US Patents 10,095,672, 10,706,221 and 11,210,456. GoFiler™ and Legato™ are trademarks of Novaworks, LLC. EDGAR® is a federally registered trademark of the U.S. Securities and Exchange Commission. Novaworks is not affiliated with or approved by the U.S. Securities and Exchange Commission. All other trademarks are property of their respective owners. Use of the features specified in this language are subject to terms, conditions and limitations of the Software License Agreement.