Json class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "<!-- Json class --> The <var>Json</var> class facilitates data exchange with [http://en.wikipedia.org/wiki/JavaScript JavaScript] programs or other programs that suport the [h...")
 
No edit summary
Line 10: Line 10:


Json objects would typically be created either programmatically using JSON constructors or by parsing a JSON string sent from another platform. A Json object tree can be examined and manipulated using a set of Json functions and the resulting object tree can be serialized as a string. The Json parsing and serialization functions operate only on unicode so a separate step is required to encode/decode the data to/from a format suitable for network transfer, most commonly [http://en.wikipedia.org/wiki/UTF-8 UTF-8].   
Json objects would typically be created either programmatically using JSON constructors or by parsing a JSON string sent from another platform. A Json object tree can be examined and manipulated using a set of Json functions and the resulting object tree can be serialized as a string. The Json parsing and serialization functions operate only on unicode so a separate step is required to encode/decode the data to/from a format suitable for network transfer, most commonly [http://en.wikipedia.org/wiki/UTF-8 UTF-8].   
==The JsonType enumeration==
The <var>JsonType</var> [[Enumerations|enumeration]] indicates the type of JSON data represented by a Json object. Json objects simulate JavaScript variables in that they are untyped so that the same variable can actually reference very different datatypes.
The values of the <var>JsonType</var> enumeration which correspond to the equivalent JSON datatypes are:
<table class="thJustBold">
<tr><th>Null</th><td>A null object value. A Json object will never have a null value but the type of a null pointer is Null.</td></tr>
<tr><th>String</th><td>A unicode string value which can be set or retrieved from a SOUL [[Unicode]] variable or expression.</td></tr>
<tr><th>Number</th><td>A number value which behaves very much like Model 204 [[Float class|Float]] variables.</td></tr>
<tr><th>Array</th><td>An ordered but un-named collection of Json objects.</td></tr>
<tr><th>Object</th><td>An ordered, named collection of Json objects.</td></tr>
</table>
<p class="note">'''Note:''' As with all enumerations, the <var>ToString</var> method implicitly converts an enumeration value to a character string whose value is the name of the enumeration value. For more information about methods available to all enumerations, see [[Enumerations#Common enumeration methods|Common enumeration methods]]. </p>


==List of Json methods==
==List of Json methods==

Revision as of 19:03, 17 February 2015

The Json class facilitates data exchange with JavaScript programs or other programs that suport the JSON format. JSON can be considered as an alternative encoding format to XML which is supported in SOUL by the XmlDoc API. The advantages of JSON over XML are:

  • It is easier to use in JavaScript programs.
  • It maps more naturally on to object-oriented structures, especially collections.
  • It is lighter-weight. That is, data represented as JSON is typically more compact than the same data represented as XML and the JSON standard is considerably simpler than the XML standard.

All that said, there are many situations where XML is a better choice for an exchange format than JSON.

Json objects would typically be created either programmatically using JSON constructors or by parsing a JSON string sent from another platform. A Json object tree can be examined and manipulated using a set of Json functions and the resulting object tree can be serialized as a string. The Json parsing and serialization functions operate only on unicode so a separate step is required to encode/decode the data to/from a format suitable for network transfer, most commonly UTF-8.

The JsonType enumeration

The JsonType enumeration indicates the type of JSON data represented by a Json object. Json objects simulate JavaScript variables in that they are untyped so that the same variable can actually reference very different datatypes.

The values of the JsonType enumeration which correspond to the equivalent JSON datatypes are:

NullA null object value. A Json object will never have a null value but the type of a null pointer is Null.
StringA unicode string value which can be set or retrieved from a SOUL Unicode variable or expression.
NumberA number value which behaves very much like Model 204 Float variables.
ArrayAn ordered but un-named collection of Json objects.
ObjectAn ordered, named collection of Json objects.

Note: As with all enumerations, the ToString method implicitly converts an enumeration value to a character string whose value is the name of the enumeration value. For more information about methods available to all enumerations, see Common enumeration methods.

List of Json methods

List of Json methods contains a complete list of the class methods.