Results 1 to 2 of 2

Thread: JSON as a Request and Response in Spring WEB MVC

  1. #1

    Default JSON as a Request and Response in Spring WEB MVC

    Hi,
    As per my requirement, I need to send JSON format object to Spring controller and also need the JSON in Response.
    Clarification: Suppose user entered Name and Age. Now I want to send the Name and age as a JSON object and then server will process the same and will return the response as JSON object. From the Response JSON object I will render the page .

    To do the same, I need help about how to send the JSON object as Request / Or if Spring can convert the request by it self. Also how to get the JSON response..

    Any help is appreciable.

  2. #2
    Join Date
    May 2010
    Posts
    20

    Default

    This link may be helpful to you if you are using any JS libraries like JQuery or Dojo.


    Other Easier way of doing this is to construct JSON object on client side and send it as string to your server to process it and get JSON response back.Something like this
    Code:
    var oData = {
          'name' : 'username',
          'age' : 100
    };
    Now send this object to server by stringifying it.
    And for the response you can use JS eval() function OR any other JSON parsers available

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •