Hi,Thanks for publishing the transit format! I've started looking into the Transit spec and the initial implementations, and I'd be interested in trying it on a future project.I started working on a toy implementation of a transit library in Haskell but I'm confused about certain points in the grammar. Here are some issues that I've noticed:
- Emitters of verbose JSON don't send cached values; however the reader specs don't indicate what should happen when cached values are encountered in the input stream.
- In concise JSON it's not clear what it would mean if a non-even number of elements follows a marker for a Hash map represented as an Array, but this isn't prohibited by the grammar (I tested in the Ruby implementation and `["^ ", 1]` throws an `ArgumentError`).
In general, given that there are reserved characters that indicate that a given string is a token that has an impact on the subsequent acceptable tokens in the stream, there seem to be JSON inputs that are implicitly invalid according to the spec. Since there isn't a BNF, though, it has been difficult for me to think through an exhaustive list of these cases, and even more difficult to write a parser. Is there a plan to put together a BNF for the format? I'd be happy to help if this is something that is desired.Thank again for releasing this format, and for any help that you may be able to provide!Justin
> JSON.parse(File.read('maps_four_char_string_keys.weird.json'))
=> [{"aaaa"=>1, "bbbb"=>2}, ["^ ", "aaaa", 3, "bbbb", 4], ["^ ", "^0", 5, "^1", 6]]
> Transit::Reader.new(:json, File.open('maps_four_char_string_keys.weird.json')).read
=> [{"aaaa"=>1, "bbbb"=>2}, {"aaaa"=>3, "bbbb"=>4}, {"aaaa"=>5, "bbbb"=>6}]
> JSON.parse(File.read('maps_four_char_string_keys.weird.json'))
=> [{"aaaa"=>1, "bbbb"=>2}, ["^ ", "aaaa", 3, "bbbb", 4], ["^ ", "^0", 5, "^1", 6]]
> Transit::Reader.new(:json, File.open('maps_four_char_string_keys.weird.json')).read
=> [{"aaaa"=>1, "bbbb"=>2}, {"aaaa"=>3, "bbbb"=>4}, {"aaaa"=>5, "bbbb"=>6}]
I understand wanting to avoid the need to configure the reader, but if that's the desire, should the reader be smart enough to detect the algorithm used by the writer and reject documents that are invalid according to the spec? The above seems to be invalid according to at least two rules that I've understood from the document - specifically that concise JSON should not contain JSON objects, and that the keys should always be cached in concise JSON based on their length.