How to find properties path in JSON?
I noticed that JSON files don't have null
values for certain properties, because they don't list the property at all... this, compared to XML, creates me lot of problems ...
I w开发者_高级运维onder if there is any function to find a property inside JSON...
I imagine something in jQuery like
$(data).find("myPropertyIneed").val();
instead of data.MainCategory.otherStuff.myPropertyIneed
Your problem is not typical for JSON at all, as it does actually have a null value that can be used on properties. Your problem is specific to whatever you use to create the data, as it on purpose leaves out properties with null values.
If you want the null values, you should first look into why they are left out in the first place.
Your problem with finding properties is not related to left out null values, or JSON at all, as you obviously already has parsed the data into Javascript object judging from how you access it.
If you want a property, you should already know it's path. Looking all over for a property doesn't make sense, as for example "data.car.loadingCapacity.length" and "data.hand.middlefinger.length" have completely different meanings.
精彩评论