I am new to using JSON. On subscribing to a webservice I receive a json response as given below.
1024760833990-36891Customercustomer realtime20110914 10:48:10NNNYYYYN{"hostName":"uat91w82m7","data":{"view":{"columnValues":[{"DisplaySymbol":"MSFT Jan 19 '13 $35 Call","Symbol":"MSFT--130119C00035000","Quantity":1.0,"Price":0.71,"ChangeValue":0.01,"ChangePercentage":1.41,"DaysGainValue":1.0,"PriceAdjusted":false}],"columnHeaderCodes":[1,2,3,4,11,5],"viewName":null,"quoteType":0,"accountNumber":"39903689","asOfDate":1316022555984,"totalMarketValue":"71.0","todaysGainValue":"1.0","annualGainValue":"0.0","pagination":{"nextPositionMarker":"","pageNumber":1,"posPerPage":500,"posDetailPerPage":50,"totalNumberofPositions":1,"markerLength":0},"viewType":3,"portfolioId":null,"customView":false,"displayNetWorth":1,"groupOptions":"G0","viewID":null,"widgetType":null,"columnHeaders":null,"totalPositionCount":0,"easternDaylight":true,"widget":false}},"smUser":"102476083","success":true,"sysdate":1316022555992,"message_info":null,"message_type":null}
I am trying to display certain parameters on my page. So how to I parse it.
ANSWER : just remove 1024760833990-36891Customercustomer realtime20110914 10:48:10NNNYYYYN through PHP or any other server side script and them parse it to jQuery, i’m damn sure it will do the job.
First paste your JSON into JSONLint.com to make sure it’s valid JSON. What you provided in your question is not valid.
Secondly you can parse it with JQuery using parseJSON or with old skool JS using JSON.parse.