Json output syntax errors

hello, thanks,

the json output file of this command generates error.
restic backup d:\files\restic --json > output.json


restic version
restic 0.14.0 compiled with go1.19 on windows/amd64

when viewing the output.json,

  1. firefox errors with
SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 2 column 1 of the JSON data
  1. notepad++ errors with
---------------------------
JSON Viewer: Error
---------------------------
There was an error while parsing JSON. Refer to the current selection for possible problematic area.

Error: (2 : The document root must not be followed by other values.)

here is output.json

{"message_type":"status","percent_done":0,"total_files":1,"total_bytes":2}
{"message_type":"status","action":"scan_finished","item":"","duration":0.2204929,"data_size":2,"data_size_in_repo":0,"metadata_size":0,"metadata_size_in_repo":0,"total_files":1}
{"message_type":"verbose_status","action":"new","item":"/d/files/restic/01.txt","duration":0.0100271,"data_size":2,"data_size_in_repo":71,"metadata_size":0,"metadata_size_in_repo":0,"total_files":0}
{"message_type":"verbose_status","action":"new","item":"/d/files/restic/","duration":0.0100271,"data_size":0,"data_size_in_repo":0,"metadata_size":291,"metadata_size_in_repo":250,"total_files":0}
{"message_type":"verbose_status","action":"new","item":"/d/files/","duration":0.0100271,"data_size":0,"data_size_in_repo":0,"metadata_size":301,"metadata_size_in_repo":256,"total_files":0}
{"message_type":"verbose_status","action":"new","item":"/d/","duration":0.0166115,"data_size":0,"data_size_in_repo":0,"metadata_size":300,"metadata_size_in_repo":257,"total_files":0}
{"message_type":"summary","files_new":1,"files_changed":0,"files_unmodified":0,"dirs_new":3,"dirs_changed":0,"dirs_unmodified":0,"data_blobs":1,"tree_blobs":4,"data_added":1190,"total_files_processed":1,"total_bytes_processed":2,"total_duration":0.2621467,"snapshot_id":"2331fcb5"}

thanks much,
david

The output is a single json document per line.

https://jsonlines.org/

2 Likes

thanks,

i found jq
it can format the text into something i can view more easily