Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with deserializing JSON to Grails

 
Hugo Alberto Bedolla
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody:

Having a problem when readin a JSON object into my controller.

when using

println params

basically I get this output:

[application[prospect][contact]:kkkk, application[prospect][SSN]:ABC123456AB0, application[applicationDate]:Tue Apr 02 2013 09:22:06 GMT-0600, application[prospect][name]:ANAMEHERE, application[prospect][address]:The Address, action:saveApplication, controller:screenApplication]

So I know there is the object.

When trying to access my object using:

println params["application"]

I get:

null

When trying to access any of its properties in this way:

println params.application.prospect.contact

I get:

null

When trying to "deserialize" using

def jsonobject = new JSONObject(JSON.parse(params["application"]))

I get:

NullPointerException

What am I doing wrong when accesing the parameters?

Kind regards


UPDATE: problem solved: It was when serializing the object to JSON with Javascript (Not proper serializing but passing the object "as is").
 
Preethi sakar
Greenhorn
Posts: 19
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi me too have same problem but can't find solution please explain me how you solved it with an example

Hugo Alberto Bedolla wrote:Hello everybody:

Having a problem when readin a JSON object into my controller.

when using

println params

basically I get this output:

[application[prospect][contact]:kkkk, application[prospect][SSN]:ABC123456AB0, application[applicationDate]:Tue Apr 02 2013 09:22:06 GMT-0600, application[prospect][name]:ANAMEHERE, application[prospect][address]:The Address, action:saveApplication, controller:screenApplication]

So I know there is the object.

When trying to access my object using:

println params["application"]

I get:

null





Thanks in advance
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic