如何将JSON stringify转换为json?
如何将JSON stringify转换为json格式。 我的代码: var socket = io.connect('URL'); socket.on('trades',function(tradeMsg){// console.log(tradeMsg); document.getElementById('trade')。innerHTML = JSON.stringify(tradeMsg)})。
**i required output json format** : ex:
{
"coin": "SPHR",
"exchange_id": "bittrex",
"market_id": "BTC_SPHR",
"message": {
"coin": "SPHR",
"msg": {
"cap24hrChange": -12.71,
"long": "Sphere",
"mktcap": 6821313,
"perc": -12.71,
"price": 2.8884325,
"shapeshift": false,
"short": "SPHR",
"supply": 3082940,
"usdVolume": 2838.85,
"volume": 2838.85,
"vwapData": 2.2126,
"vwapDataBTC": 2.2126
}
},
"msg": {
"cap24hrChange": -12.71,
"long": "Sphere",
"mktcap": 6821313,
"perc": -12.71,
"price": 2.8884325,
"shapeshift": false,
"short": "SPHR",
"supply": 3082940,
"usdVolume": 2838.85,
"volume": 2838.85,
"vwapData": 2.2126,
"vwapDataBTC": 2.2126
},
"trade": {
"data": {
"exchange_id": "bittrex",
"market_id": "BTC_SPHR",
"price": 2040.8163,
"raw": {
"Id": 6508626,
"TimeStamp": "2017-10-24T08:48:51.533",
"Quantity": 9.252431,
"Price": 4.9E-4,
"Total": 0.00453369,
"FillType": "FILL",
"OrderType": "SELL"
},
"timestamp_ms": 1508834952474,
"volume": 0.004533691
}
}
}
在这里你首先需要解析json字符串。 例如
var object = JSON.parse("string");
现在对象包含您所需的Json OBJECT
链接地址: http://www.djcxy.com/p/48233.html