MATLAB: JSON decode – lost information

jsonjsondecodeMATLABwebread

Let's say I get this string from the serverside;
{"1D2381B":["fd56c0fd-8882-4b8e-9941-0bd04489981e"],"BZ5ZZ65":["2c768773-7d5f-4d06-8fa1-6ce819dc383a"],"11852420":["b8953809-a264-41b3-a1c3-f3592cd51419"]}
I want to be able to parse and use this information. Matlab automagically decodes it… but it 'makes valid names' of my IDs.
As modifying an ID somewhat destroys it's utility. I'd like a way to prevent or otherwise recover the information. The function 'makeValidNames' returns a second argument, which says which entries were modified.
This information is lost in the JSON decode function. Can anyone help with a workaround, on how I can convert this without the destruction of information?

Best Answer

It's something I've complained about to Mathworks in the early days of jsondecode. In fact, you can use matlab jsonencode to encode a matlab.containers.Map that you would not be able to read back correctly with jsondecode due to that mangling of json keys.
I suggested that jsondecode returns a matlab.containers.Map instead which wouldn't require name mangling and the developer did say that it was something they were considering for a future release. Either they have decided against it or it's yet to be implemented.
I suggest that you raise a service request to Mathworks. The more people complain, the more likely it will change.
In the meantime, I'm afraid you'll have to delegate to a 3rd party parser or write your own. It's not that difficult to parse json actually.
Related Question