Skip to content

Commit 19d4277

Browse files
authored
(DOCS-10675): Remove $literal from first $arrayToObject example (#2193) (#2216)
* change to brackets * tech review feedback * tech review feedback pt 2 * copy review feedback
1 parent 2f2d612 commit 19d4277

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

source/reference/operator/aggregation/arrayToObject.txt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Definition
2525

2626
.. code-block:: none
2727

28-
[ [ "item", "abc123"], [ "qty", 25 ] ]
28+
[ [ [ "item", "abc123" ], [ "qty", 25 ] ] ]
2929

3030
\- OR -
3131

@@ -38,7 +38,7 @@ Definition
3838

3939
.. code-block:: none
4040

41-
[ { "k": "item", "v": "abc123"}, { "k": "qty", "v": 25 } ]
41+
[ [ { "k": "item", "v": "abc123" }, { "k": "qty", "v": 25 } ] ]
4242

4343
:expression:`$arrayToObject` has the following syntax:
4444

@@ -70,7 +70,7 @@ If the name of a field repeats in the array,
7070

7171
.. list-table::
7272
:header-rows: 1
73-
:widths: 80 20
73+
:widths: 60 40
7474
:class: border-table
7575

7676
* - Example
@@ -79,21 +79,24 @@ If the name of a field repeats in the array,
7979
* - .. code-block:: json
8080
:copyable: false
8181

82-
{ $arrayToObject: { $literal: [
83-
{ "k": "item", "v": "abc123"},
84-
{ "k": "qty", "v": 25 }
85-
] } }
82+
{ $arrayToObject: [
83+
[ { "k": "item", "v": "abc123" },
84+
{ "k": "qty", "v": "$qty" } ]
85+
] }
8686

87-
- .. code-block:: json
88-
:copyable: false
87+
- Given a document with the field ``qty`` and value ``25``,
88+
:expression:`$arrayToObject` returns:
8989

90+
.. code-block:: json
91+
:copyable: false
92+
9093
{ "item" : "abc123", "qty" : 25 }
9194

9295
* - .. code-block:: json
9396
:copyable: false
9497

9598
{ $arrayToObject: { $literal: [
96-
[ "item", "abc123"], [ "qty", 25 ]
99+
[ "item", "abc123" ], [ "qty", 25 ]
97100
] } }
98101

99102
- .. code-block:: json
@@ -105,7 +108,7 @@ If the name of a field repeats in the array,
105108
:copyable: false
106109

107110
{ $arrayToObject: { $literal: [
108-
{ "k": "item", "v": "123abc"},
111+
{ "k": "item", "v": "123abc" },
109112
{ "k": "item", "v": "abc123" }
110113
] } }
111114

0 commit comments

Comments
 (0)