News for hackers. Stuff that matters.
Re:Son: A minimal subset of JSON for machine-to-machine comm... by Derbasti on Sunday December 10, 2017 @07:58AM (#15891205)
To be fair, MATLAB only added support for reading/writing JSON this very year. And they represent JSON objects as structs, which don't support all key names, and they have a very "idiomatic" idea of which JSON arrays are decoded as matrices or cells, and how nested arrays sometimes result in nested arrays, and sometimes result in multi-dimensional arrays. And there's an uneasy relationship between the empty array and Null. It is kind of a mess, really.
Re:Son: A minimal subset of JSON for machine-to-machine comm... by radarsat1 on Sunday December 10, 2017 @09:39AM (#15891546)
Also to be fair, although I can see some uses for supporting JSON in MATLAB, it makes a lot more sense if you're using an array language to use an array-oriented format such as HDF5, which has been supported in all the major numerical platforms for quite a while.
Re:Son: A minimal subset of JSON for machine-to-machine comm... by sundarurfriend on Sunday December 10, 2017 @12:27PM (#15892385)
> It is kind of a mess, really.

Honestly, that statement applies to pretty much any part of MATLAB unless the behaviour is nailed down by existing mathematical or engineering specifications - and I'm talking as someone that likes MATLAB overall. Mathworks tries a bit to polish and paint it as a coherent whole, but it's patchwork of things built upon and stuck to the sides of the existing structure, optimizing towards a particular kind of "pragmatism" than towards any kind of elegance.

Re:Son: A minimal subset of JSON for machine-to-machine comm... by ansgri on Sunday December 10, 2017 @08:02AM (#15891218)
I remember my colleague working with JSON in MATLAB via some thirdparty library about 2 or 3 years ago. It was regex-based, it was slow as hell but at least it was available.
Re:Son: A minimal subset of JSON for machine-to-machine comm... by Derbasti on Sunday December 10, 2017 @03:22PM (#15893293)
Fun fact, I wrote my own JSON reader/writer in pure MATLAB, and it is also regex-based, and in many cases, it is faster than MATLAB's own, Mex-based JSON reader/writer: https://github.com/bastibe/transplant

There are few things as slow as non-vectorized MATLAB code. MATLAB's regex engine is pretty decent, actually, and supports quite a few fancy tricks. For example, I use the regex engine to find the start/end of all numbers and strings ahead of time, and for replacing escape sequences (even unicode escapes!) with their literal characters. The former is particularly important because otherwise, you'd have to manually iterate over characters until you find the end of strings or numbers, which is unacceptably slow in MATLAB.