Flex 4.5中你如何检查JSON子节点存在的关键(使用的hasOwnProperty或其他方法) [英] Flex 4.5 How do you check for JSON child node key existence (using hasOwnProperty or other methods)
问题描述
你如何检查JSON子节点存在的关键在Flex 4.5中使用的hasOwnProperty(或其他方式)?
How do you check for JSON child node key existence using hasOwnProperty (or other methods) in Flex 4.5?
在的hasOwnProperty
方法可以检查JSON键的存在,但这似乎只在一个JSON顶级节点,而不是子节点的工作。例如,如果你有JSON的结构是这样的(可读的形式,SAN的JSON语法),你可以检查的 callresponder.lastResponse.hasOwnKey(位置)的存在
,但似乎没有办法检查 Location.VenueName
例如:
The hasOwnProperty
method can check for JSON key existence but this seems to only work with top level nodes in a JSON, and not the child nodes. For example, if you have JSON structure like this (in a readable form, sans the JSON syntax), you can check for the existence of callresponder.lastResponse.hasOwnKey("Location")
, but there seems no way to check for Location.VenueName
for example or any of the children:
Name:
Location:
(child) VenueName:
(child) Address:
(child) City:
(child) State:
.
.
. (etc)
的问题是,我的数据源,省略了子键时,信息不可用,所以这将是很好能够为您在Flex中做别的事情,需要先参考的JSON键的存在。
The issue is that my data source omits the child key when the information is not available, so it would be nice to be able to check for the existence of the JSON key in a reference in Flex before doing anything else for it.
最明显的 callresponder.lastResponse.hasOwnKey(Location.VenueName)
不起作用。
问:我如何检查JSON键 Location.VenueName
的存在?
Q: How would I check if the JSON key Location.VenueName
exists?
推荐答案
更明显的是
callresponder.lastResult.Location.hasOwnProperty("VenueName");
这应该工作。
Which should work.
这篇关于Flex 4.5中你如何检查JSON子节点存在的关键(使用的hasOwnProperty或其他方法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!