My situation is crazy. I'm creating a JSON object, which is perfectly fine from server side end. But, this is not getting acceptable due to extra " which is created via server side. My server side code is
String id = "123";
String hql = "FROM Person E WHERE E.userId = "+id;
Query query = session.createQuery(hql);
List<?> results = query.list();
JSONArray arr = new JSONArray();
JSONObject obj = new JSONObject();
for(int i = 0; i < results.size(); i++) {
Personalisation p = (Personalisation) results.get(i);
obj.put("courseId", p.getCourseId());
obj.put("CourseValue", p.getCourseValue());
}
System.out.println(obj);
It is printing
{"CourseValue":"{\"color\": \"green\",\"value\": \"#f00\"}","courseId":"C5"}
This is fine from server side end. You could see extra " before {\"color tag, when I try to parse the same thing on client side, it doesnt accept due to illegal character. What should I need to do?
Here is the fiddle too http://jsfiddle.net/hLkUz/43/