@@ -23,7 +23,7 @@ Definition
23
23
24
24
.. code-block:: none
25
25
26
- [ [ "item", "abc123"], [ "qty", 25 ] ]
26
+ [ [ [ "item", "abc123" ], [ "qty", 25 ] ] ]
27
27
28
28
\- OR -
29
29
@@ -36,7 +36,7 @@ Definition
36
36
37
37
.. code-block:: none
38
38
39
- [ { "k": "item", "v": "abc123"}, { "k": "qty", "v": 25 } ]
39
+ [ [ { "k": "item", "v": "abc123" }, { "k": "qty", "v": 25 } ] ]
40
40
41
41
:expression:`$arrayToObject` has the following syntax:
42
42
@@ -68,7 +68,7 @@ If the name of a field repeats in the array,
68
68
69
69
.. list-table::
70
70
:header-rows: 1
71
- :widths: 80 20
71
+ :widths: 60 40
72
72
:class: border-table
73
73
74
74
* - Example
@@ -77,21 +77,24 @@ If the name of a field repeats in the array,
77
77
* - .. code-block:: json
78
78
:copyable: false
79
79
80
- { $arrayToObject: { $literal: [
81
- { "k": "item", "v": "abc123"},
82
- { "k": "qty", "v": 25 }
83
- ] } }
80
+ { $arrayToObject: [
81
+ [ { "k": "item", "v": "abc123" },
82
+ { "k": "qty", "v": "$qty" } ]
83
+ ] }
84
84
85
- - .. code-block:: json
86
- :copyable: false
85
+ - Given a document with the field ``qty`` and value ``25``,
86
+ :expression:`$arrayToObject` returns:
87
87
88
+ .. code-block:: json
89
+ :copyable: false
90
+
88
91
{ "item" : "abc123", "qty" : 25 }
89
92
90
93
* - .. code-block:: json
91
94
:copyable: false
92
95
93
96
{ $arrayToObject: { $literal: [
94
- [ "item", "abc123"], [ "qty", 25 ]
97
+ [ "item", "abc123" ], [ "qty", 25 ]
95
98
] } }
96
99
97
100
- .. code-block:: json
@@ -103,7 +106,7 @@ If the name of a field repeats in the array,
103
106
:copyable: false
104
107
105
108
{ $arrayToObject: { $literal: [
106
- { "k": "item", "v": "123abc"},
109
+ { "k": "item", "v": "123abc" },
107
110
{ "k": "item", "v": "abc123" }
108
111
] } }
109
112
0 commit comments