PDA

View Full Version : Not able to retrieve JSON Object in Json format on the Server side.



rushi2440
28 Dec 2011, 2:22 AM
Hi.. sencha forum member i need one help from you.

I am developing an application in which I am interacting with the database using proxy api: create, read, update, destroy.

I am done to read the data from the server side. Now I want to create new record by passing data from the view to my server side controller.

When i click the save button my create api calls and execute POST that interact of the controller.
after clicking the save button my json data submitted is



JSON













taskdata

[Object { Name="New task", StartDate="2010-02-13T05:30:00", EndDate="2010-02-23T05:30:00", more...}]



0

Object { Name="New task", StartDate="2010-02-13T05:30:00", EndDate="2010-02-23T05:30:00", more...}



Duration

1



DurationUnit

"d"



EndDate

"2010-02-23T05:30:00"



Id

null



ManuallyScheduled

false



Name

"New task"



PercentDone

0



Priority

1



StartDate

"2010-02-13T05:30:00"



checked

null



depth

1



index

2



parentId

null









Source



{"taskdata":[{"Id":null,"Name":"New task","StartDate":"2010-02-13T05:30:00","EndDate":"2010-02-23T05:30:00","Duration":1,"DurationUnit":"d","PercentDone":0,"ManuallyScheduled":false,"Priority":1,"parentId":null,"index":2,"depth":1,"checked":null}]}




on the server side when i print the data which i had passed it gives me

{ taskdata = [{
Id = null,
Name = New task,
StartDate = 2010 - 02 - 13T05: 30: 00,
EndDate = 2010 - 02 - 23T05: 30: 00,
Duration = 1,
DurationUnit = d,
PercentDone = 0,
ManuallyScheduled = false,
Priority = 1,
parentId = null,
index = 2,
depth = 1,
checked = null
}]
}

what mistake i am making that my json data is full converted to Array. I want my data to be in json format only.

I am using spring for the server side beans management and the controller to make my work done.

my function that gives me above output is

@RequestMapping(value= "/task/CreateTask.action") public @ResponseBody Map<String, ? extends Object> createTask(@RequestBody Map<String, Object> taskdata) throws Exception {
try {
System.out.println("INSIDE CREATE TASK :"+taskdata);
List<Task> tasks = ganttService.createTask(taskdata);
return getMapTask(tasks);
}catch(Exception e) {
return getModelMapError("Error in creating Task");
}
}

Yogendra Singh
Sr. Programmer
Kintudesigns.com

jay@moduscreate.com
28 Dec 2011, 6:54 AM
your JSON is OK. I'm confused as to what doesn't work and why. All you've shown is the server side stuff. :(