本文介绍了如何从JSON括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSON字符串像下面

  [    {
        名称:TEST,
        DEVICEID:,
        CartId:,
        时间戳:1383197265540,
        餐饮: [],
        城市:伦敦CA
     }]

我要删除/从string..So除去第一和最后一个方括号我如何从上面的字符串使用JavaScript除去第一和最后一个方括号。

请帮我


解决方案

  VAR tmpStr =[
    {
        名称:TEST,
        DEVICEID:,
        CartId:,
        时间戳:1383197265540,
        餐饮: [],
        城市:伦敦CA
     }]';变种中newstr = tmpStr.substring(1,tmpStr。长度-1);

I have one json string like below

[

    {
        "Name": "TEST",
        "deviceId": "",
        "CartId": "",
        "timestamp": 1383197265540,
        "FOOD": [],
        "City": "LONDON CA"
     }

]

I want to delete/remove the first and last square brackets from string..So how would I remove the first and last square brackets from the above string using javascript.

Please help me

解决方案
var tmpStr = '[    
    {
        "Name": "TEST",
        "deviceId": "",
        "CartId": "",
        "timestamp": 1383197265540,
        "FOOD": [],
        "City": "LONDON CA"
     }

]';

var newStr = tmpStr.substring(1, tmpStr .length-1);

这篇关于如何从JSON括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 03:27