Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by

I already have a lot of data written with the :json writer, but I am thinking of switching to the :json-verbose writer, so I'll have a mix JSON in both formats. It seems that the :json reader handles :json-verbose writes fine, but I just want to make sure.

2 Answers

+2 votes
by

Yes, at least it's in the spec. According to https://github.com/cognitect/transit-format,

Note that there are two write modes for JSON. In normal JSON mode,
caching is enabled (explained below) and maps are represented as
arrays with a special marker element. There is also JSON-Verbose mode,
which is less efficient, but easier for a person to read. In
JSON-Verbose mode, caching is disabled and maps are represented as
JSON objects. This is useful for configuration files, debugging, or
any other situation where readability is more important than
performance. A JSON reader is expected to transparently handle data
written in either mode and to remain unaware of which mode was used to
write the data.

(emphasis mine)

0 votes
by

Maybe, but I'd be careful.

This table makes it seem like there may be at least some differences:

https://github.com/cognitect/transit-format#ground-and-extension-types

Specifically, the rows with "extension" "point in time" look maybe sketchy.

by
Thanks for the heads up Harold,

I'm using custom handlers for date and time anyway, so I don't think it should be an issue for my data.
by
For sure. Seems like a great case for automated tests, imo. One could imagine systems that automatically write out both formats and read them in in various ways to ensure continuous availability of that functionality (if it's really necessary). Defining a representative set of documents will also help, so when something does inevitably go wrong, you can identify regressions to discover what you didn't expect, and grow that set of documents/tests over time to improve coverage. Good luck.
...