jQuery access JSON Object

后端 未结 5 1779
梦毁少年i
梦毁少年i 2021-02-06 04:14

How do I access the name of an item in an Object Literal using jQuery?

For example how would I read \"title\", \"link\", \"media\", ect... in this

{
             


        
5条回答
  •  臣服心动
    2021-02-06 04:38

    In your case, this is not an array at all! You want to loop through properties of an object.

    JavaScript does not truly support associative arays either... see http://www.hunlock.com/blogs/Mastering_Javascript_Arrays

    Zed's answer is perfect, I would add

    alert(json[key]);
    

    inside the for, if you wonder how to get the value of the propery

    Thanks

提交回复
热议问题