The addon convert/json ignores all but the first element of a
(non-boxed) array when using enc_json.

   enc_json 3 2 1
3
   enc_json 3 2 1;4 3 2
[3,4]
   enc_json <"_1 ]3 2 1
[3,2,1]
   enc_json <"_1 ]i.3 3
[0,3,6]

Is there a reason for this behavior? I realize that encoding 3 2 1 as
"[3,2,1]" is ambiguous (since (<"_1]3 2 1) has the same encoding), but
encoding as "3" seems even worse since it destroys data rather than
formatting.

Is there a way around it without modifying the convert/json code? Of
course applying <"0 L:0 beforehand will suffice, but it is rather
inefficient and decodes to a boxed structure. The best possible solution
would be one that encodes any J noun unambiguously into reasonable JSON,
but either of the following would be useful:
- A method of conversion where dec_json is an exact inverse to end_json,
  but the intermediate JSON may not make sense (e.g. it has extra
  decorations for J arrays).
- A way of making any J noun a into another noun a1 such that
  a -: dec_json enc_json a1 .

Thanks,
Marshall
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to