Skip to content

Single map inside a list, list is not preserved #15

@jpaasen

Description

@jpaasen

I have the following simple json-file that does not remain the same if you read it using loadjson and then store it with savejson (using the master branch and Matlab 2014b).

{
    "test1":[
        {
            "A":0,
            "B":1
        }
    ],
    "test2":{
        "C":2,
        "D":3
    }
}

The '[]' brackets are removed. I know that arrays with single elements is quite problematic in Matlab, but it looks like you now, compared to older versions, are able to create a cell-array holding a single struct. At least that is what I see printed in the console after loading the example file.

test = loadjson('test.json')
test = 
     test1 : {[1x1 struct]}
     test2 : [1x1 struct]

Would it be possible to use this information when storing the json file to preserve the single element list?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions