I have a nested array that I would like to convert to JSON.
Header row
data row 1
data row 2
(etc.)
MAT←1 3⍴ 'Name' 'Age' 'Zipcode'
MAT←MAT,[1]'Bob' '21' '30102'
MAT←MAT,[1]'Sally' '32' '43001'
]disp MAT
┌→────┬───┬───────┐
↓Name │Age│Zipcode│
├────→┼──→┼──────→┤
│Bob │21 │30102 │
├────→┼──→┼──────→┤
│Sally│32 │43001 │
└────→┴──→┴──────→┘
My objective is to convert the APL array into a JSON string:
'[{"Name":"Bob","Age":"21","Zipcode":"30102"},{"Name":"Sally","Age":"32","Zipcode":"43001"}]'
And... the inverse as well ..
from JSON string back to nested array.
I can force all numbers to be text via ⍕ converting 21 to '21' inside MAT ahead of time.
I would like to work with all text strings in all cells.
Thoughts?
Sincere thanks!
//W