Javascript 如何获取 JSON 中的特定元素
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5683171/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 18:26:27 来源:igfitidea点击:
How to get specific element in JSON
提问by rabid_zombie
If I have JSON that is:
如果我有 JSON,那就是:
var response = {results: 2938; id: 9283};
How can I get id using javascript/jquery?
如何使用 javascript/jquery 获取 id?
I tried something like but I can't seem to get what I want (I want to get the number in id):
我试过类似的东西,但我似乎无法得到我想要的(我想得到 id 中的数字):
response[1]
and
和
response[1].id
采纳答案by Mark Coleman
回答by Quentin
Just response.id
. You don't need anything more.
只是response.id
。你不再需要任何东西。
回答by Jage
You should just need to use:
你应该只需要使用:
response.id
回答by integrater
dynamic func_param = JsonConvert.DeserializeObject(key);
foreach (var invoicekey in func_param)
{
var invoice = merchelloHelper.Query.Invoice.GetByKey(Guid.Parse(invoicekey.Value));
}