在JSON对象中查找密钥存在 [英] Find the key existence in JSON object
本文介绍了在JSON对象中查找密钥存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个JSON字符串
I have a JSON string
String str = '{ "name":"John", "age":31, "city":"New York" }'
在上面的字符串中, city 是可选键,并且可能不会出现在JSON数据中。
In the above string, city is an optional key and may not be present in the JSON data.
我解码了json字符串
I decoded the json string
var jsonResponse = json.decode(str);
我想知道 city 键的存在, > jsonResponse 对象。
I want to get to know the existence of city key the jsonResponse object.
推荐答案
jsonResponse.containsKey( key);
这篇关于在JSON对象中查找密钥存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文