Tech-invite3GPPspaceIETFspace
21222324252627282931323334353637384‑5x

Content for  TS 32.161  Word version:  18.0.0

Top   Top   Up   Prev   Next
0…   5…   6…   7…   A…   B…   C…   D…

 

6  Mapping of JSON to the XPath data modelp. 9

6.1  Mapping of JSON documentsp. 9

A JSON document is mapped to the (conceptual) root node. The root node has no name.

6.2  Mapping of scalar valuesp. 9

A scalar value in JSON is a string, a number, or one of the tree literal names true, false or null. These values are mapped to text nodes. Text nodes in the XPath 1.0 data model have no further qualification with a data type. However, a Jex processor shall store the original data type used in the JSON document.
Note that JSON strings are enclosed by quotation marks, JSON numbers are not enclosed by quotation marks, and the three tree literal names true, false or null are not enclosed by quotation marks either. In other words, it is possible to deduct the type of the scalar value in a JSON document by inspecting the value itself.
Up

6.3  Mapping of name/value pairsp. 9

6.3.1  Case: The value is a scalarp. 9

The name of the name/value pair is mapped to an element node. The name of the element node is equal to the name of the name/value pair.
The value of the name/value pair is mapped to a text node as described in clause 9.3.3.
The text node coming from the value of a mapped name/value pair is the child of the element node coming from the name of the mapped name/value pair. Vice versa, the element node coming from the name of the mapped name/value pair is the parent of the text node coming from the value of the mapped name/value pair.
Examples:
The data type of the scalar value is number.
"a": 1
<a>1</a>
The data type of the scalar value is string.
"a": "string"
<a>string</a>
The data type of the scalar value is the literal name null.
"a": null
<a>null</a>
The data type of the scalar value is the literal name true.
"a": true
<a>true</a>
The data type of the scalar value is the literal name false.
"a": false
<a>false</a>
Up

6.3.2  Case: The value is a JSON objectp. 9

The name of the name/value pair is mapped to an element node. The name of the element node is equal to the name of the name/value pair.
The value of the name/value pair consists of an unordered list of name/value pairs. Each name of these name/value pairs is mapped to an element node. No order can be assumed for these element nodes.
The element nodes coming from the value of the mapped name/value pair are children of the element node coming from the name of the mapped name/value pair. Vice versa, the element node coming from the name of the mapped name/value pair is the parent of the element nodes coming from the value.
Example:
"a": {
  "b": 1,
  "c": 2
}
<a>
  <b>1</b>
  <c>2</c>
</a>
or
"a": {
  "b": 1,
  "c": 2
}
<a>
  <c>2</c>
  <b>1</b>
</a>
"a": {
  "b": 1,
  "c": {
    "d": 2,
    "e": 3
  }
}
<a>
  <b>1</b>
  <c>
    <d>2</d>
    <e>3</e>
  </c>
</a>
Up

6.3.3  Case: The value is a JSON arrayp. 10

The name of the name/value pair is mapped to a specific number of element nodes. The number of element nodes is equal to the number of array items. The names of these element nodes are all identical and equal to the name of the name/value pair.
The order of element nodes is the same as the order of the array items in the corresponding JSON.
The element nodes coming from the value of the mapped name/value pair are children of the element node coming from the name of the mapped name/value pair. Vice versa, the element node coming from the name of the name/value pair is the parent of the element nodes coming from the array items of the JSON array.
Example:
"a": [
  1,
  2,
  3
]
<a>1</a>
<a>2</a>
<a>3</a>
"a": [
  {"b": 1,
   "c": 2
  },
  {"b": 3,
   "c": 4
  },
  {"b": 5,
   "c": 6
  },
]
<a>
  <b>1</b>
  <c>2</c>
</a>
<a>
  <b>3</b>
  <c>4</c>
</a>
<a>
  <b>5</b>
  <c>6</c>
</a>
Up

6.3.4  XPath data model concepts required by JSONp. 11

A JSON document is mapped to root nodes, element nodes and text nodes. Attribute nodes, namespace nodes, processing instruction nodes and comment nodes have no equivalent in JSON.
The concept of document order is applicable only for element nodes coming from JSON arrays.
The concept of variables is not used in Jex.
The root node in the XPath 1.0 data model may have only one element node as child (the document element). This restriction is relaxed in Jex. The root node may have any number of element nodes as children.
Example:
{
  "a": 1,
  "b": 2,
  "c": 3
}
<a>1</a>
<b>2</b>
<c>3</c>
Up

Up   Top   ToC