javascript - How to Create JS Object from string -


i have string value (according console.log()):

j:{"address":"north road 34 ","zip":"00002 ","state":"texas ","city":"dallas ","country":"us"}

i dont know why starts letter 'j', interested in inside it. have tried json.parse() throws error: 'unexpected token: 'j'.

the eval() solution doesn't seems work either , throws 'unexpected token: ':'

thank you!

well... explanation shouldn't start j: since it's invalid json, (probably because of bug).

you can fix string make valid removing invalid prefix json string.

var obj = json.parse(yourstring.replace(/^j:/, '')); 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -