Closed sheljohn closed 8 years ago
@Sheljohn There is MergeCell
option that changes the behavior. See function help.
Setting MergeCell
to false yields struct('bar',{{1},{2},{3}})
, which is still not the desired output.
@Sheljohn Then implement your own parsing rule. Matlab treats everything as an array, and there is always an ambiguity in parse rule. See README.
That is simply wrong, there is no ambiguity when it comes to parsing either cells or arrays, the only missing information in JSON is about the shape of the containers.
@Sheljohn Yes, but embedding shape information is not possible with the current JSON spec, unless preparing the shape field in every object.
You missed the point of the issue I think; I have no problem with the shape of the output, it is the type that is wrong.
@Sheljohn See README for the current conversion rule. It is impossible to distinguish a numeric array from cell arrays in the JSON spec. Perhaps you can customize the parser implementation for your own purpose.
It is impossible to distinguish a numeric array from cell arrays in the JSON spec.
This is wrong. You should probably realise that valid arrays of arrays in Matlab are always arrays, and therefore arrays of arrays in JSON can be used to represent cells without ambiguity.
@Sheljohn This parser implementation is designed primarily for N-D array usage, and that's why the parsing rule is defined in the following way (from README). MergeCell
option controls this behavior. If you need something else, you are free to hack the implementation.
Right. Saying that there is no full and reversible mapping between JSON and Matlab is wrong though, so these claims should probably be removed from the README. I will stop bothering you with this bug as you seem to have no intention of fixing it, and because I think it was your intent to settle for a partial non-reversible mapping. Apologies for the trouble
I would expect the following JSON:
to be parsed as
struct('bar',{1,2,3})
(or a cell column), but instead it gets parsed asstruct('bar',[1;2;3])
.