1. #1
    Sencha User
    Join Date
    Apr 2011
    Location
    Surat, Gujarat, India
    Posts
    126
    Vote Rating
    0
    rushi2440 is on a distinguished road

      0  

    Thumbs up Unanswered: Not able to retrieve JSON Object in Json format on the Server side.

    Unanswered: Not able to retrieve JSON Object in Json format on the Server side.


    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
    Code:
    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
    Code:
    {    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
    Code:
    @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

  2. #2
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Answers
    102
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    your JSON is OK. I'm confused as to what doesn't work and why. All you've shown is the server side stuff.

Thread Participants: 1

Tags for this Thread