[erlang-questions] javascript . notation to fetch objects from JSON decode_string/1
Matthew Williamson
dawsdesign@REDACTED
Wed Aug 13 16:55:08 CEST 2008
Try out the mochiweb json module. It's at
http://code.google.com/p/mochiweb/source/browse/trunk/src/mochijson.erl. I
think all you need to do is call mochijson:decode(JSON) and you get a native
erlang data structure.
On Wed, Aug 13, 2008 at 8:27 AM, Bharani <bharani_vms@REDACTED> wrote:
>
> Hi,
>
> I am relatively new to Erlang and i have been playing with ejson for a
> while. Right now to access nested objects i am using a function like
>
> json_find(Json,[]) -> Json;
> json_find(Json,[H|T])-> {ok,JsonNew}=json:obj_find(H,Json),find(JsonNew,T).
>
> get(Json,Key)->
> json_find(Json,string:tokens(Key,"."))
> .
>
> so that i can simple say get(<json string>,"obj1.obj2.field")
>
> is this right way to do or can any one point out best practices
>
> Thanks
> Bharani
> --
> View this message in context:
> http://www.nabble.com/javascript-.-notation-to-fetch-objects-from-JSON-decode_string-1-tp18962077p18962077.html
> Sent from the Erlang Questions mailing list archive at Nabble.com.
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080813/a3420f54/attachment.htm>
More information about the erlang-questions
mailing list