JSON deserialization in 1.1

42 views
Skip to first unread message

Rob Dawson

unread,
Oct 11, 2010, 3:49:41 AM10/11/10
to play-fr...@googlegroups.com
Hi guys,

It seems that some of the JSON handling behaviour has changed between 1.0.3 and 1.1 RC1.

In 1.0.3.2 I could have an action:

public static void invoke(String message)

and then have the message parameter set with the following AJAX call:

var jsonData=JSON.stringify({"message": "hello" });
$.ajax({
type: "post",
contentType: "application/json",
url: "/Service/invoke",
data: jsonData,
success: responseHandler,
processData: false,
dataType: "json"
});

In 1.1RC1 the message parameter does not get set.

Is the change in behaviour desired?

Thanks,

Rob

Erwan Loisant

unread,
Oct 11, 2010, 3:57:36 AM10/11/10
to play-fr...@googlegroups.com
Hi,

It's probably not linked to your problem but I don't think you need to
stringify your JSON object, jQuery will do that for you if you just
pass an object. That way it would work in browsers that don't have the
JSON object.

Now could you post a full Play app that works in 1.0 but not 1.1? The
best would be to trim it down so only the used code is included. At
least the Java code of /Service/invoke would help.

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

--
Erwan Loisant

Rob Dawson

unread,
Oct 11, 2010, 7:12:33 AM10/11/10
to play-fr...@googlegroups.com
Hi,

Just putting together the simple app now.

in my tests on chrome with old versions of jquery I did need the JSON.stringify. The json2.js http://www.json.org/js.html has the implementation of json.stringify for broken browsers.

I'll create a bug for you.

Regards,

Rob

Rob Dawson

unread,
Oct 11, 2010, 7:26:39 AM10/11/10
to play-fr...@googlegroups.com

Guillaume Bort

unread,
Oct 11, 2010, 7:26:40 AM10/11/10
to play-fr...@googlegroups.com
Yes it was an undocumented feature but pretty buggy. So during the
internal refactoring of the binder we don't have migrated it yet. I
would prefer waiting for a next release to have a better
implementation.

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com

Rob Dawson

unread,
Oct 11, 2010, 8:14:29 AM10/11/10
to play-fr...@googlegroups.com
ok -- I won't comment about the bugginess in 1.0 ;)

fwiw I ended up writing a custom plugin to handle json binding in 1.0. (after some of the guys on my time fixed up my threading bugs it works pretty well :)).

The plugin uses the gson code to bind to the parameters, skipping the multiple parser layers in the 1.0 implementation, instead using the beforeInvocation(), bind(), and invocationFinally() plugin hooks to do the binding.

Rob

Guillaume Bort

unread,
Oct 11, 2010, 12:43:17 PM10/11/10
to play-fr...@googlegroups.com
Nice, can you share it?

>>> fram...@googlegroups.com.


>>> To unsubscribe from this group, send email to play-framewor...@googlegroups.com
>>> .
>>> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en
>>> .
>>>
>>>
>>
>>
>>

>> --
>> Guillaume Bort, http://guillaume.bort.fr
>>
>> For anything work-related, use g...@zenexity.fr; for everything else,
>> write guillau...@gmail.com
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "play-framework" group.
>> To post to this group, send email to play-fr...@googlegroups.com.
>> To unsubscribe from this group, send email to play-framewor...@googlegroups.com
>> .

Rob Dawson

unread,
Oct 20, 2010, 5:01:28 PM10/20/10
to play-fr...@googlegroups.com
Sorry about the delay in responding. I'll start following up on getting it shared today.

Rob

>>>>>> To post to this group, send email to play-fr...@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

>>>>>> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Erwan Loisant
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google Groups "play-framework" group.

>>>>> To post to this group, send email to play-fr...@googlegroups.com.
>>>>> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

>>>>> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>>>>>
>>>>

>>>> --
>>>> You received this message because you are subscribed to the Google Groups "play-framework" group.
>>>> To post to this group, send email to play-fr...@googlegroups.com.
>>>> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

>>>> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>>>>
>>>>
>>>
>>>
>>>

>>> --
>>> Guillaume Bort, http://guillaume.bort.fr
>>>
>>> For anything work-related, use g...@zenexity.fr; for everything else,
>>> write guillau...@gmail.com
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups "play-framework" group.
>>> To post to this group, send email to play-fr...@googlegroups.com.
>>> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

>>> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>>>
>>

>> --
>> You received this message because you are subscribed to the Google Groups "play-framework" group.
>> To post to this group, send email to play-fr...@googlegroups.com.
>> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

>> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>>
>

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages