Try: for (var i in object) {}
Where object would be your json object. Leon Derks wrote: > Hi Sven, > > I only see that they get the value by using the key name. > For example this: > > |var data = '{ "name": "Violet", "occupation": "character" }'.evalJSON(); > data.name; //prints Violet. > | > > But in my case, I don't know the key name, so I can't get the value. > Is there a way to get the key names of a JSON Object? > For example something like this: > | > data.keys; //returns {name, occupation}| > > | > | > > Leon > > > Sven Homburg wrote: >> http://www.prototypejs.org/learn/json >> >> 2008/5/15 Leon Derks <[EMAIL PROTECTED]>: >> >> >>> Hello >>> >>> I have a JSON object like this: >>> >>> JSONObject obj = new JSONObject(); >>> >>> obj.put(entity.getId(), entity.getName()); >>> >>> But how can I get the value from my json object in javascript, if I >>> don't >>> know the key name? >>> >>> Is there a way to get the key name(s) from a json object in javascript? >>> >>> Leon >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >>> >> >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- http://thegodcode.net --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]