github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/parser/create-object.md (about) 1 # `%{}` Create Map 2 3 > Quickly generate objects and maps 4 5 ## Description 6 7 `%{}` is a way of defining objects in expressions and statements. Whenever an 8 `%{}` object is outputted as a string, it will be converted to minified JSON. 9 10 Object elements inside `%{}` can be new line and/or comma delimited. This 11 allows for compatibility with JSON but without the pain of accidentally invalid 12 comma management breaking JSON parsers. However a colon is still required to 13 separate keys from values. 14 15 Like with YAML, strings in `%[]` do not need to be quoted unless you need to 16 force numeric or boolean looking values to be stored as strings. 17 18 19 20 ## Examples 21 22 **Object passed as a JSON string:** 23 24 ``` 25 » echo %{foo: bar} 26 {"foo":"bar"} 27 ``` 28 29 **The `%` prefix for the nested object is optional:** 30 31 ``` 32 » %{foo: bar, baz: [1 2 3]} 33 { 34 "baz": [ 35 1, 36 2, 37 3 38 ], 39 "foo": "bar" 40 } 41 ``` 42 43 ## See Also 44 45 * [Special Ranges](../mkarray/special.md): 46 Create arrays from ranges of dictionary terms (eg weekdays, months, seasons, etc) 47 * [`"Double Quote"`](../parser/double-quote.md): 48 Initiates or terminates a string (variables expanded) 49 * [`%(Brace Quote)`](../parser/brace-quote.md): 50 Initiates or terminates a string (variables expanded) 51 * [`%[]` Create Array](../parser/create-array.md): 52 Quickly generate arrays 53 * [`'Single Quote'`](../parser/single-quote.md): 54 Initiates or terminates a string (variables not expanded) 55 * [`expr`](../commands/expr.md): 56 Expressions: mathematical, string comparisons, logical operators 57 58 <hr/> 59 60 This document was generated from [gen/parser/create_object_doc.yaml](https://github.com/lmorg/murex/blob/master/gen/parser/create_object_doc.yaml).