Gajendra24
Gajendra24

Reputation: 43

How to convert HttpResponse of contentType text/html to JSON in JAVA

Below is the response I am getting from HttpRequest. I want to return this response in JSON to Ajax request from spring controller.

({
   'KUI': {
       code: '.KUI',
       indexDetailEnable: true,
       price: '20,650.21',
       netChange: '-13.01',
       percentChange: '-0.06%',
       tradeDate: '17/04/03',
       tradeTime: '16:50',
       chartDate: '17/04/03',
       chartTime: '16:50'
    },

   'KUI': {
       code: '.NHK',
       indexDetailEnable: true,
       price: '--',
       netChange: '--',
       percentChange: '--%',
       tradeDate: '--/--/--',
       tradeTime: '--:--',
       chartDate: '17/04/03',
       chartTime: '17:15'
    },

    __end__: null
});

Upvotes: 0

Views: 1853

Answers (1)

Bartha Barna
Bartha Barna

Reputation: 24

you could use new JSONObject(yourResponse) or new JSONArray(youResponse) from org.json

Upvotes: 1

Related Questions