| Author |
Message |
|
| Guest |
Posted: Mon Jun 02, 2008 6:21 pm |
|
|
|
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 |
|
|
| Back to top |
|
| Guest |
Posted: Sat Jun 07, 2008 2:14 pm |
|
|
|
Guest
|
|
| Back to top |
|
| Guest |
Posted: Sat Jun 07, 2008 6:18 pm |
|
|
|
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 .
>
> 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 |
|
|
| Back to top |
|
| Guest |
Posted: Sat Jun 07, 2008 7:21 pm |
|
|
|
Guest
|
Will post the code on the mailing list once I get it working. Thanks
for the help
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 .
>
> > 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 |
|
|
| Back to top |
|
| Guest |
Posted: Sun Jun 08, 2008 5:54 pm |
|
|
|
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
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
>
> 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 .
>
> > > 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 |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
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
|
|
|