github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/types/jsonc.md (about)

     1  # `jsonc`
     2  
     3  > Concatenated JSON
     4  
     5  ## Description
     6  
     7  The following description is taken from [Wikipedia](https://en.wikipedia.org/wiki/JSON_streaming#Concatenated_JSON):
     8  
     9  > Concatenated JSON streaming allows the sender to simply write each JSON
    10  > object into the stream with no delimiters. It relies on the receiver using
    11  > a parser that can recognize and emit each JSON object as the terminating
    12  > character is parsed. Concatenated JSON isn't a new format, it's simply a
    13  > name for streaming multiple JSON objects without any delimiters.
    14  >
    15  > The advantage of this format is that it can handle JSON objects that have
    16  > been formatted with embedded newline characters, e.g., pretty-printed for
    17  > human readability. For example, these two inputs are both valid and produce
    18  > the same output:
    19  >
    20  > #### Single line concatenated JSON
    21  >
    22  >     {"some":"thing\n"}{"may":{"include":"nested","objects":["and","arrays"]}}
    23  >
    24  > #### Multi-line concatenated JSON
    25  >
    26  >     {
    27  >       "some": "thing\n"
    28  >     }
    29  >     {
    30  >       "may": {
    31  >         "include": "nested",
    32  >         "objects": [
    33  >           "and",
    34  >           "arrays"
    35  >         ]
    36  >       }
    37  >     }
    38  
    39  ## Examples
    40  
    41  Because of the similiaries with jsonlines (`jsonl`), the examples here will
    42  focus on jsonlines examples. However concatenated JSON doesn't need a new line
    43  separator. So the examples below could all be concatenated into one long line.
    44  
    45  Example JSON lines documents taken from [jsonlines.org](http://jsonlines.org/examples/)
    46  
    47  ### Tabulated data
    48  
    49  ```
    50  ["Name", "Session", "Score", "Completed"]
    51  ["Gilbert", "2013", 24, true]
    52  ["Alexa", "2013", 29, true]
    53  ["May", "2012B", 14, false]
    54  ["Deloise", "2012A", 19, true] 
    55  ```
    56  
    57  This format is equatable to `generic` and `csv`.
    58  
    59  ### Nested objects
    60  
    61  ```
    62  {"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]}
    63  {"name": "Alexa", "wins": [["two pair", "4♠"], ["two pair", "9♠"]]}
    64  {"name": "May", "wins": []}
    65  {"name": "Deloise", "wins": [["three of a kind", "5♣"]]}
    66  ```
    67  
    68  ## Detail
    69  
    70  ### Similarities with `jsonl`
    71  
    72  The advantage of concatenated JSON is that it supports everything jsonlines
    73  supports but without the dependency of a new line as a separator.
    74  
    75  Eventually it is planned that this Murex data-type will replace jsonlines
    76  and possibly even the regular JSON parser. However this concatenated JSON
    77  parser currently requires reading the entire file first before parsing whereas
    78  jsonlines can read one line at a time. Which makes jsonlines a better data-
    79  type for pipelining super large documents. For this reason (and that this
    80  parser is still in beta), it is shipped as an additional data-type.
    81  
    82  ## Default Associations
    83  
    84  * **Extension**: `concatenated-json`
    85  * **Extension**: `json-seq`
    86  * **Extension**: `jsonc`
    87  * **Extension**: `jsonconcat`
    88  * **Extension**: `jsons`
    89  * **Extension**: `jsonseq`
    90  * **MIME**: `application/concatenated-json`
    91  * **MIME**: `application/json-seq`
    92  * **MIME**: `application/jsonc`
    93  * **MIME**: `application/jsonconcat`
    94  * **MIME**: `application/jsonseq`
    95  * **MIME**: `application/x-concatenated-json`
    96  * **MIME**: `application/x-json-seq`
    97  * **MIME**: `application/x-jsonc`
    98  * **MIME**: `application/x-jsonconcat`
    99  * **MIME**: `application/x-jsonseq`
   100  * **MIME**: `text/concatenated-json`
   101  * **MIME**: `text/concatenated-json`
   102  * **MIME**: `text/json-seq`
   103  * **MIME**: `text/jsonc`
   104  * **MIME**: `text/jsonconcat`
   105  * **MIME**: `text/jsonseq`
   106  * **MIME**: `text/x-json-seq`
   107  * **MIME**: `text/x-jsonc`
   108  * **MIME**: `text/x-jsonconcat`
   109  * **MIME**: `text/x-jsonseq`
   110  
   111  
   112  ## Supported Hooks
   113  
   114  * `Marshal()`
   115      Supported
   116  * `ReadArray()`
   117      Works with JSON arrays. Maps are converted into arrays
   118  * `ReadArrayWithType()`
   119      Works with JSON arrays. Maps are converted into arrays. Element data type is `json` 
   120  * `ReadIndex()`
   121      Works against all properties in JSON
   122  * `ReadMap()`
   123      Not currently supported.
   124  * `ReadNotIndex()`
   125      Works against all properties in JSON
   126  * `Unmarshal()`
   127      Supported
   128  * `WriteArray()`
   129      Supported
   130  
   131  ## See Also
   132  
   133  * [`*` (generic)](../types/generic.md):
   134    generic (primitive)
   135  * [`[[ Element ]]`](../parser/element.md):
   136    Outputs an element from a nested structure
   137  * [`cast`](../commands/cast.md):
   138    Alters the data type of the previous function without altering it's output
   139  * [`csv`](../types/csv.md):
   140    CSV files (and other character delimited tables)
   141  * [`foreach`](../commands/foreach.md):
   142    Iterate through an array
   143  * [`format`](../commands/format.md):
   144    Reformat one data-type into another data-type
   145  * [`hcl`](../types/hcl.md):
   146    HashiCorp Configuration Language (HCL)
   147  * [`json`](../types/json.md):
   148    JavaScript Object Notation (JSON)
   149  * [`jsonl`](../types/jsonl.md):
   150    JSON Lines
   151  * [`open`](../commands/open.md):
   152    Open a file with a preferred handler
   153  * [`pretty`](../commands/pretty.md):
   154    Prettifies JSON to make it human readable
   155  * [`runtime`](../commands/runtime.md):
   156    Returns runtime information on the internal state of Murex
   157  * [`toml`](../types/toml.md):
   158    Tom's Obvious, Minimal Language (TOML)
   159  * [`yaml`](../types/yaml.md):
   160    YAML Ain't Markup Language (YAML)
   161  * [index](../parser/item-index.md):
   162    Outputs an element from an array, map or table
   163  * [mxjson](../types/mxjson.md):
   164    Murex-flavoured JSON (deprecated)
   165  
   166  ### Read more about type hooks
   167  
   168  - [`ReadIndex()` (type)](../apis/ReadIndex.md): Data type handler for the index, `[`, builtin
   169  - [`ReadNotIndex()` (type)](../apis/ReadNotIndex.md): Data type handler for the bang-prefixed index, `![`, builtin
   170  - [`ReadArray()` (type)](../apis/ReadArray.md): Read from a data type one array element at a time
   171  - [`WriteArray()` (type)](../apis/WriteArray.md): Write a data type, one array element at a time
   172  - [`ReadMap()` (type)](../apis/ReadMap.md): Treat data type as a key/value structure and read its contents
   173  - [`Marshal()` (type)](../apis/Marshal.md): Converts structured memory into a structured file format (eg for stdio)
   174  - [`Unmarshal()` (type)](../apis/Unmarshal.md): Converts a structured file format into structured memory
   175  
   176  <hr/>
   177  
   178  This document was generated from [builtins/types/jsonconcat/jsonconcat_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/types/jsonconcat/jsonconcat_doc.yaml).