Saravana Kumar
Saravana Kumar

Reputation: 179

How to remove parentheses from JSON in start and end?

I have a Json Object look like ,

({
    "result":[{
        "key":"value".....
    }]
})

I don't know how to remove the parentheses from the starting and ending of the JSON like ( and ). Please guide me.

Upvotes: 4

Views: 1579

Answers (2)

SakthiSureshAnand
SakthiSureshAnand

Reputation: 1362

For the Sake I took your JSON as a sample Input below

var test = ({
            "result":[{
                "key":"value"
            }]
        });

Using JSON.stringify(test) you removed these thing ( start and ) End

Output like below

{"result":[{"key":"value"}]}

Upvotes: 1

Khalisaran Saran
Khalisaran Saran

Reputation: 324

My guess is that you are trying to access JSONP data. You probably need to add ?callback=? to your URL

var url="http://www.somedata.com";
    $.getJSON(url+'?callback=?', function(json){
        //loop through deals
        $.each(json.people,function(i,dat){
            $("#todaycal").append("<li>"+dat.name+"  "+dat.caseNo+"</li>");
        });
        $("#todaycal").listview('refresh');
    });

Upvotes: 2

Related Questions