> var arr = { };
undefined
> arr['aa'] = 111;
111
> arr['bb'] = 222;
222
> arr
{ aa: 111, bb: 222 }
> var json = JSON.stringify(arr); // dictionary to json string
undefined
> typeof(json);
'string'
> json
'{"aa":111,"bb":222}'
> JSON.parse(json); // json decode
{ aa: 111, bb: 222 }
Reference :
Encoding Javascript Object to Json string - Stack Overflow
How to parse JSON in JavaScript - Stack Overflow
沒有留言:
張貼留言