Erlang Mailing Lists

Author Message

<  Erlyweb mailing list  ~  serving json

Guest
Posted: Mon Jun 02, 2008 6:21 pm Reply with quote
Guest
Hi all,
I want to serve/render json from erlyweb controllers. Czn somebody
please help me out with this or point me to some resource.

--
Regards
Abhijith
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist
Guest
Posted: Sat Jun 07, 2008 2:14 pm Reply with quote
Guest
I know that there is a json module in mochiweb:
http://code.google.com/p/mochiweb/source/browse/trunk/src/mochijson.erl.
Let me know if you get it working in erlyweb Smile.

Cheers,
Dan

On Jun 3, 3:20
Guest
Posted: Sat Jun 07, 2008 6:18 pm Reply with quote
Guest
There's also a json module in Yaws (but feel free to use whichever you
like better). The way I would use it is as follows:

{response, [{html, json:encode({array, ["foo", "bar", {struct,
[{"key", "val"}]}]})}]}

Yariv

On Sat, Jun 7, 2008 at 7:13 AM, Dan Bravender <dan.bravender@gmail.com> wrote:
>
> I know that there is a json module in mochiweb:
> http://code.google.com/p/mochiweb/source/browse/trunk/src/mochijson.erl.
> Let me know if you get it working in erlyweb Smile.
>
> Cheers,
> Dan
>
> On Jun 3, 3:20 am, Abhijith <abhiji...@gmail.com> wrote:
>> Hi all,
>> I want to serve/render json from erlyweb controllers. Czn somebody
>> please help me out with this or point me to some resource.
>>
>> --
>> Regards
>> Abhijith
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist
Guest
Posted: Sat Jun 07, 2008 7:21 pm Reply with quote
Guest
Will post the code on the mailing list once I get it working. Thanks
for the help Smile


On Jun 7, 10:10 pm, "Yariv Sadan" <yarivsa...@gmail.com> wrote:
> There's also a json module in Yaws (but feel free to use whichever you
> like better). The way I would use it is as follows:
>
> {response, [{html, json:encode({array, ["foo", "bar", {struct,
> [{"key", "val"}]}]})}]}
>
> Yariv
>
> On Sat, Jun 7, 2008 at 7:13 AM, Dan Bravender <dan.braven...@gmail.com> wrote:
>
> > I know that there is a json module in mochiweb:
> >http://code.google.com/p/mochiweb/source/browse/trunk/src/mochijson.erl.
> > Let me know if you get it working in erlyweb Smile.
>
> > Cheers,
> > Dan
>
> > On Jun 3, 3:20 am, Abhijith <abhiji...@gmail.com> wrote:
> >> Hi all,
> >> I want to serve/render json from erlyweb controllers. Czn somebody
> >> please help me out with this or point me to some resource.
>
> >> --
> >> Regards
> >> Abhijith
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist
Guest
Posted: Sun Jun 08, 2008 5:54 pm Reply with quote
Guest
Thanks for your help guys. Got the json thingy working.

Dan, mochijson works out of the box. I used mochijson2.erl. I have
tried it out with 3 implementations of JSON and all three seem to
work. I have tried only encoding so far ,I dare say other functions
will work. Anyways, here's the code for the dummy controller that I
wrote and thank you once again for the link Smile

RENDERING JSON FOR A ERLYWEB CONTROLLER
----------------------------------------------------------------------------------
Code below illustrates how to render JSON and raw HTML/TEXT from a
controller.
----------------------------------------------------------------------------------
-module(mock_controller).
-export([index/1, mochi_test/1, lshift_test/1, yaws_test/1]).

index(_) ->
{ response, [ { html, <<"<b>hello json</
b>">> } ] }.

mochi_test(_) ->
{ response, [ { html, mochijson2:encode({struct, [{'mochi',
'json2'}]}) } ] }. %% mochiweb JSON implementation

lshift_test(_) ->
{ response, [ { html, rfc4627:encode({obj, [{'lshift',
'rfc4627'}]}) } ] }. %% rfc4627/Lshift JSON implementation

yaws_test(_) ->
{ response, [ { html, json:encode({struct, [{"yaws",
"json"}]}) } ] }. %% YAWS json implementation

-----------------------------------------------------------------------------------------------------------------------------------
Regards,
Abhijith

On Jun 8, 12:20 am, Abhijith <abhiji...@gmail.com> wrote:
> Will post the code on the mailing list once I get it working. Thanks
> for the help Smile
>
> On Jun 7, 10:10 pm, "Yariv Sadan" <yarivsa...@gmail.com> wrote:
>
> > There's also a json module in Yaws (but feel free to use whichever you
> > like better). The way I would use it is as follows:
>
> > {response, [{html, json:encode({array, ["foo", "bar", {struct,
> > [{"key", "val"}]}]})}]}
>
> > Yariv
>
> > On Sat, Jun 7, 2008 at 7:13 AM, Dan Bravender <dan.braven...@gmail.com> wrote:
>
> > > I know that there is a json module in mochiweb:
> > >http://code.google.com/p/mochiweb/source/browse/trunk/src/mochijson.erl.
> > > Let me know if you get it working in erlyweb Smile.
>
> > > Cheers,
> > > Dan
>
> > > On Jun 3, 3:20 am, Abhijith <abhiji...@gmail.com> wrote:
> > >> Hi all,
> > >> I want to serve/render json from erlyweb controllers. Czn somebody
> > >> please help me out with this or point me to some resource.
>
> > >> --
> > >> Regards
> > >> Abhijith
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum