2.1 JSON data types

Iris interfaces use JSON data types. The JSON type system provides clarity and simplicity and is supported by all relevant programming languages.

In this topic, Value represents any of the following JSON types or constants:

  • Object. A map from String to Value.
  • Array. A list of Values, not necessarily of the same type.
  • String.
  • Number. Represents integer and floating point values of arbitrary precision. Iris avoids using the arbitrary Number type.
  • Boolean.
  • True.
  • False.
  • Null.

The term NumberU64 refers to a uint64_t, in the range 0 to 264-1.

The term NumberS64 refers to an int64_t, in the range -263 to 263-1.

The term Type[] refers to an array of Type values. For example String[] is an array of strings. Value[] is semantically identical to Array.

The term Map[String]Type refers to a map or dictionary-like object where the type of the key is String and the type of the value is Type. For example, Map[String]NumberU64 is a map or dictionary object with String keys and NumberU64 values. Map keys are always Strings. Map[String]Value is semantically identical to Object.

The following table defines the implicit type conversions that are performed on the interface boundary. The first column contains the values to convert from:

Table 2-1 Implicit type conversions

Original value To Number To NumberU64 To NumberS64 To Boolean To Object To Array To String
Number -/✓ (Round)(Range) -/✓ (Round)(Range) -/✓ (Round)(only 1/0) - - -
NumberU64 -/✓ (Range) -/✓ (only 1/0) - - -
NumberS64 -/✓ (Range) -/✓ (only 1/0) - - -
Boolean ✓ (to 1/0) ✓ (to 1/0) ✓ (to 1/0) - - -
Object - - - - - -
Array - - - - - -
String - - - - - -

Key:

Implicitly converted.
-Not converted. E_*_type_mismatch error.
(Round)Floating point numbers are implicitly rounded to the nearest integer.
(Range)Implicitly converted when in range, else E_*_type_mismatch error.
(only 1/0)Numbers are converted to Booleans when they are 1 (True) or 0 (False), else E_*_type_mismatch error, which is stricter than C, C++, and Python.
(to 1/0)Booleans are implicitly converted to numbers as 1 (True) or 0 (False), as in C, C++, and Python.

Note:

  • The Iris interface only expects and produces U64 and S64 numbers. Other numbers can be passed to Iris functions and are converted according to this table.
  • Null is not implicitly converted to or from anything else.
Non-ConfidentialPDF file icon PDF version101196_0100_00_en
Copyright © 2018 Arm Limited or its affiliates. All rights reserved.