From: jason joo Date: 2010-08-12T14:46:44+09:00 Subject: Re: does jason convert to hash? --000e0cd32746137911048d99e4e1 Content-Type: text/plain; charset=ISO-8859-1 i wrote a test because ur code cannot be run on my machine require 'json' items = JSON.parse('{"test":12334, "test1": [{"a":1,"b":2},2,3]}') items["test1"][0].each{|item| p item } it looks good a hash can be "each" so try to "p" the variable before "each" it? 2010/8/12 Samuel Sternhagen > jason joo wrote: > > in ur example data there are only 3 items in the "result" and the > > element of > > "count" has a value of 52 > > in ur for-loop u will access 3-51 ones which do not exist > > u may use table["results"].size instead of table["count"] > > > > 2010/8/12 Samuel Sternhagen > > In my while loop I am using "table["count"]. If you run this code it > produces output that starts with: > > > "{\"count\":52,\"results\":[{\"name\":\"getMethodTable\",\"description\":\"Get > a list of all methods > > available.\",\"uri\":\"\\/\",\"params\":null,\"defaults\":null,\"type\":\"method\",\"visibility\":\"public\",\"http_method\":\"GET\"} > > My while loop is using table["count"] as the limit. Sorry for the > confusion. > -- > Posted via http://www.ruby-forum.com/. > > --000e0cd32746137911048d99e4e1--