how to convert JSON stringify to json?

how to convert JSON stringify to json format.? My code: 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
      }
   }
}

here you go first you need to parse json string. for example

var object = JSON.parse("string");

now object contains your required Json OBJECT

链接地址: http://www.djcxy.com/p/48234.html

上一篇: 在不同文件夹中的bash脚本中创建符号链接

下一篇: 如何将JSON stringify转换为json?