开发者

How to get specific element in JSON

开发者 https://www.devze.com 2023-02-25 17:51 出处:网络
If I have J开发者_如何学PythonSON that is: var response = {results: 2938; id: 9283}; How can I get id using javascript/jquery?

If I have J开发者_如何学PythonSON that is:

var response = {results: 2938; id: 9283};

How can I get id using javascript/jquery?

I tried something like but I can't seem to get what I want (I want to get the number in id):

response[1]

and

response[1].id


Simple:

response.id

With that being said, your json is invalid,

var response = {results: 2938; id: 9283};

Use a , to separate items not a ;

var response = {results: 2938, id: 9283};

And since I love jsfiddle so much, here is an example.


Just response.id. You don't need anything more.


You should just need to use:

response.id


dynamic func_param = JsonConvert.DeserializeObject(key);

foreach (var invoicekey in func_param)
{
    var invoice = merchelloHelper.Query.Invoice.GetByKey(Guid.Parse(invoicekey.Value));
}
0

精彩评论

暂无评论...
验证码 换一张
取 消