JSON and Text Format Description
#################################

Both formats are exported by serializing protobuf messages, each on a new line.
First, all collected events are processed. Then strings are serialized,
followed by stdout, stderr streams if any, followed by thread names.

Output layout:

.. code-block:: text

    {Event #1}
    {Event #2}
    ...
    {Event #N}
    {Strings}
    {Streams}
    {Threads}


For easier grepping of JSON output, the ``--line-by-line`` switch may be used to
force manual splitting of strings, streams and thread names data.

Example line split: ``./nsys export --export-json --line-by-line sample.qdrep -- -``

.. code-block:: json

    {"type":"String","id":"3720","value":"Process 14944 was launched by the profiler"}
    {"type":"String","id":"3721","value":"Profiling has started."}
    {"type":"String","id":"3722","value":"Profiler attached to the process."}
    {"type":"String","id":"3723","value":"Profiling has stopped."}
    {"type":"ThreadName","globalTid":"72057844756653436","nameId":"14","priority":"10"}
    {"type":"ThreadName","globalTid":"72057844756657940","nameId":"15","priority":"10"}
    {"type":"ThreadName","globalTid":"72057844756654400","nameId":"24","priority":"10"}


Compare with: ``./nsys export --export-json sample.qdrep -- -``

.. code-block:: json

    {"data":["[Unknown]","[Unknown kernel module]","[Max depth]","[Broken backtraces]","[Called from Java]","QnxKernelTrace","mm_","task_submit","class_id","syncpt_id","syncpt_thresh","pid","tid","FTrace","[NSys]","[NSys Comms]", "..." ,"Process 14944 was launched by the profiler","Profiling has started.","Profiler attached to the process.","Profiling has stopped."]}
    {"data":[{"nameIdx":"14","priority":"10","globalTid":"72057844756653436"},{"nameIdx":"15","priority":"10","globalTid":"72057844756657940"},{"nameIdx":"24","priority":"10","globalTid":"72057844756654400"}]}

Note, that only last few lines are shown here for clarity.
