ios - Rails "as_json" method returning invalid json? -


i trying have ios application read json generated rails server. now, having text file, eventual goal retrieved via route.

the ios application throwing errors trying read (which generated as_json):

{"created_at"=>fri, 16 aug 2013 13:21:07 utc +00:00, "gender"=>"m", "id"=>1, "location_id"=>1, "max_hit_points"=>nil, "my_name"=>"jim bob", "npc_type_id"=>nil, "universe_id"=>1, "updated_at"=>fri, 16 aug 2013 13:21:07 utc +00:00}  

when give json validator (http://jsonformatter.curiousconcept.com)

i several errors everything, how has "=>" rather colon.

am doing weird? why rails seem not generate valid json? there somehow multiple types of valid json (arrows vs colons?) how can make generate json ios app (or validator) likes?

as_json used prepare hash suitable json rendering. (see doc)

you need call to_json real json string.

for example :

your_object.as_json.to_json 

more info on difference , implications can found here


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo