| Author |
Message |
< Yaws mailing list ~ Yaws & Dojo: json error (and maybe a fix) |
| Guest |
Posted: Tue Aug 22, 2006 6:17 pm |
|
|
|
Guest
|
Hi,
I'm trying to use Dojo's json service with yaws (on Win XP).
Otherwise it would seem to work, but when making a json call from dojo
with no arguments I get an error:
=ERROR REPORT==== 22-Aug-2006::12:28:09 ===
{yaws_rpc,126,
{html,client2erl,
"{\"params\":[],\"method\":\"contentB\",\"id\":10}",
{badmatch,{}}}}
It would seem that in function decode_handler_payload/2 the
following code causes problems:
{array, Args} = jsonrpc:s(Obj, params)
In this case jsonrpc:s(Obj, params) returns {}, which doesn't match
{array, Args}.
If I understand the code correctly, the reason jsonrpc:s(Obj, params)
returns {} can be found in json:parse_array/2
parse_array(C, Kv) ->
get_token(C, fun
(eof, C2) -> {done, {error, premature_eof}, C2};
(rsbrace, C2) -> Kv({}, C2); % empty array
(T, C2) -> parse_array([], T, C2, Kv)
end).
where {} is returned for empty array instead of {array, []}, which is
what decode_handler_payload/2 expects.
Replacing
(rsbrace, C2) -> Kv({}, C2); % empty array
with
(rsbrace, C2) -> Kv({array, []}, C2); % empty array
in json:parse_array worked for me but as I'm total newbie with
erlang/yaws/json, I'm not entirely confident that this is the
correct way to solve the problem.
Looking forward to hear your comments.
BR,
Juhani
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| rsaccon |
Posted: Tue Aug 22, 2006 6:31 pm |
|
|
|
User
Joined: 09 Aug 2006
Posts: 144
|
Oh yeah, also trapped into this at my first days with yaws/dojo/JSON,
but I was even more novice and did the brain-dead workaround of using
just a dummy argument and only now I got reminded of that. To me, your
correction makes perfect sense.
On 8/22/06, juhani@juranki.com <juhani@juranki.com> wrote:
> Hi,
>
> I'm trying to use Dojo's json service with yaws (on Win XP).
> Otherwise it would seem to work, but when making a json call from dojo
> with no arguments I get an error:
>
> =ERROR REPORT==== 22-Aug-2006::12:28:09 ===
> {yaws_rpc,126,
> {html,client2erl,
> "{\"params\":[],\"method\":\"contentB\",\"id\":10}",
> {badmatch,{}}}}
>
> It would seem that in function decode_handler_payload/2 the
> following code causes problems:
>
> {array, Args} = jsonrpc:s(Obj, params)
>
> In this case jsonrpc:s(Obj, params) returns {}, which doesn't match
> {array, Args}.
>
> If I understand the code correctly, the reason jsonrpc:s(Obj, params)
> returns {} can be found in json:parse_array/2
>
> parse_array(C, Kv) ->
> get_token(C, fun
> (eof, C2) -> {done, {error, premature_eof}, C2};
> (rsbrace, C2) -> Kv({}, C2); % empty array
> (T, C2) -> parse_array([], T, C2, Kv)
> end).
>
> where {} is returned for empty array instead of {array, []}, which is
> what decode_handler_payload/2 expects.
>
> Replacing
>
> (rsbrace, C2) -> Kv({}, C2); % empty array
>
> with
>
> (rsbrace, C2) -> Kv({array, []}, C2); % empty array
>
> in json:parse_array worked for me but as I'm total newbie with
> erlang/yaws/json, I'm not entirely confident that this is the
> correct way to solve the problem.
>
> Looking forward to hear your comments.
--
Roberto Saccon
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| Gaspar |
Posted: Tue Aug 22, 2006 7:43 pm |
|
|
|
User
Joined: 20 Jul 2006
Posts: 55
|
Hello all!
Dear Claes, CC'ing you this mail, because it 100% makes sense to patch
this line in json:parse_array -- probably we have missed this case when
were patching json.erl behave like xmlrpc module - so this change
> Replacing
>
> (rsbrace, C2) -> Kv({}, C2); % empty array
>
> with
>
> (rsbrace, C2) -> Kv({array, []}, C2); % empty array
is correct. Probably it's easier to you to fix directly in working
files(json.erl , line 478) , than applying patch
Thanks to juhani for discovering this bug
/Gaspar
juhani@juranki.com wrote:
> Hi,
>
> I'm trying to use Dojo's json service with yaws (on Win XP).
> Otherwise it would seem to work, but when making a json call from dojo
> with no arguments I get an error:
>
> =ERROR REPORT==== 22-Aug-2006::12:28:09 ===
> {yaws_rpc,126,
> {html,client2erl,
> "{\"params\":[],\"method\":\"contentB\",\"id\":10}",
> {badmatch,{}}}}
>
> It would seem that in function decode_handler_payload/2 the
> following code causes problems:
>
> {array, Args} = jsonrpc:s(Obj, params)
>
> In this case jsonrpc:s(Obj, params) returns {}, which doesn't match
> {array, Args}.
>
> If I understand the code correctly, the reason jsonrpc:s(Obj, params)
> returns {} can be found in json:parse_array/2
>
> parse_array(C, Kv) ->
> get_token(C, fun
> (eof, C2) -> {done, {error, premature_eof}, C2};
> (rsbrace, C2) -> Kv({}, C2); % empty array
> (T, C2) -> parse_array([], T, C2, Kv)
> end).
>
> where {} is returned for empty array instead of {array, []}, which is
> what decode_handler_payload/2 expects.
>
> Replacing
>
> (rsbrace, C2) -> Kv({}, C2); % empty array
>
> with
>
> (rsbrace, C2) -> Kv({array, []}, C2); % empty array
>
> in json:parse_array worked for me but as I'm total newbie with
> erlang/yaws/json, I'm not entirely confident that this is the
> correct way to solve the problem.
>
> Looking forward to hear your comments.
>
> BR,
> Juhani
>
>
>
--
Gaspar Chilingarov
System Administrator,
Network security consulting
t +37493 419763 (mob)
i 63174784
e nm@web.am
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Wed Aug 23, 2006 7:39 am |
|
|
|
Guest
|
Gaspar Chilingarov wrote:
> Hello all!
>
> Dear Claes, CC'ing you this mail, because it 100% makes sense to patch
> this line in json:parse_array -- probably we have missed this case when
> were patching json.erl behave like xmlrpc module - so this change
>
>> Replacing
>>
>> (rsbrace, C2) -> Kv({}, C2); % empty array
>>
>> with
>>
>> (rsbrace, C2) -> Kv({array, []}, C2); % empty array
>
> is correct. Probably it's easier to you to fix directly in working
> files(json.erl , line 478) , than applying patch
Excellent, in CVS now.
/klacke
--
Claes Wikstrom -- Caps lock is nowhere and
http://www.tail-f.com -- everything is under control
cellphone: +46 70 2097763
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived 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 can attach files in this forum You can download files in this forum
|
|
|