Saturday, 15 June 2013

javascript - replace string of json with another string -



javascript - replace string of json with another string -

i have json string

i got string converting

var json = org.cometd.json.tojson(envelope.messages); "[{\"version\": \"1.0\", \"minimumversion\": \"0.9\", \"channel\": \"/meta/handshake\", \"supportedconnectiontypes\": [\"long-polling\", \"callback-polling\"], \"advice\": {\"timeout\": 60000, \"interval\": 0}, \"id\": \"1\"}]"

and need replace symbols, need output

[{"version":"1.0","minimumversion":"0.9","channel":"/meta/handshake","supportedconnectiontypes":["long-polling","callback-polling"],"advice":{"timeout":60000,"interval":0},"id":"1"}]

means symbols replaced \\ "" , "[ [ , ]" ]

help me if posible.

you can simple utilize json.parse()

var json = "[{\"version\": \"1.0\", \"minimumversion\": \"0.9\", \"channel\": \"/meta/handshake\", \"supportedconnectiontypes\": [\"long-polling\", \"callback-polling\"], \"advice\": {\"timeout\": 60000, \"interval\": 0}, \"id\": \"1\"}]" json.parse(json);

javascript json

No comments:

Post a Comment