0

Creating json object in controller,

    JSONObject jObject = new JSONObject();
    try {
        JSONArray jArray = new JSONArray();
          for (BaseLoad b : bagsToLink) {
              JSONObject loadJSON = new JSONObject();
              loadJSON.put("Name", b.getName());
              loadJSON.put("Load", b.getLoad());
              jArray.put(loadJSON);
           }
        jObject.put("loadList", jArray);
        uldSelector.setJsonObject(jObject.toString());
   } catch (JSONException jse) {
        jse.printStackTrace();
    }

sending jsonObject as string from controller, jsonObject is something like this:

    {"loadList":[{"Name":"AAAA","Load":"N GND"},
                  {"Name":"BBBB","Load":"N GND"},
                  {"Name":"CCCC","Load":"N GND"},
                  {"Name":"DDDD","Load":"N GND"}]
     } );

I need to use the above text in a java script confirm window like,

Name:AAAA Load:N GND
Name:BBBB Load:N GND
Name:CCCC Load:N GND
Name:DDDD Load:N GND

what I am doing is var obj = $.parseJSON( ${jsonObject} ); but obj turn out to be null!

Any help is appreciated!

4
  • Could you show some more code? Sep 19, 2013 at 13:23
  • @DirkLachowski added how I am creating the json string in controller Sep 19, 2013 at 13:27
  • If the JSON-String you are trying to parse is really the one you are showing in your question then it's malformed (the ');' at the end). Could you check that? Sep 19, 2013 at 13:35
  • @DirkLachowski where is it? i didn't see anything wrong Sep 19, 2013 at 14:23

1 Answer 1

1

As i can't add an image to a comment, here it is, as an answer.

Malformed part

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.