Skip to content

Commit bcf7bcc

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

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
@@ -23,7 +23,7 @@ Definition
2323

2424
.. code-block:: none
2525

26-
[ [ "item", "abc123"], [ "qty", 25 ] ]
26+
[ [ [ "item", "abc123" ], [ "qty", 25 ] ] ]
2727

2828
\- OR -
2929

@@ -36,7 +36,7 @@ Definition
3636

3737
.. code-block:: none
3838

39-
[ { "k": "item", "v": "abc123"}, { "k": "qty", "v": 25 } ]
39+
[ [ { "k": "item", "v": "abc123" }, { "k": "qty", "v": 25 } ] ]
4040

4141
:expression:`$arrayToObject` has the following syntax:
4242

@@ -68,7 +68,7 @@ If the name of a field repeats in the array,
6868

6969
.. list-table::
7070
:header-rows: 1
71-
:widths: 80 20
71+
:widths: 60 40
7272
:class: border-table
7373

7474
* - Example
@@ -77,21 +77,24 @@ If the name of a field repeats in the array,
7777
* - .. code-block:: json
7878
:copyable: false
7979

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+
] }
8484

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

88+
.. code-block:: json
89+
:copyable: false
90+
8891
{ "item" : "abc123", "qty" : 25 }
8992

9093
* - .. code-block:: json
9194
:copyable: false
9295

9396
{ $arrayToObject: { $literal: [
94-
[ "item", "abc123"], [ "qty", 25 ]
97+
[ "item", "abc123" ], [ "qty", 25 ]
9598
] } }
9699

97100
- .. code-block:: json
@@ -103,7 +106,7 @@ If the name of a field repeats in the array,
103106
:copyable: false
104107

105108
{ $arrayToObject: { $literal: [
106-
{ "k": "item", "v": "123abc"},
109+
{ "k": "item", "v": "123abc" },
107110
{ "k": "item", "v": "abc123" }
108111
] } }
109112

0 commit comments

Comments
 (0)