Menu

Problem with JSONArry.

Help
2006-08-31
2013-04-29
  • Rubem Azenha

    Rubem Azenha - 2006-08-31

    Hi there,

    I got a Collection of Books and i'm trying to "renderize" it into JSON notation. Book is a bean with 3 attributes: id (Long), name (String) and author (String).

    I try something like this:

    JSONArray json = new JSONArray(books);
    out.write(json);

    Where out = servlet output
    Books = a collection of Books.

    But in the servlets output, it goes something like that:

    XML Parsing Error: syntax error
    Location: http://localhost:8080/book/book.findByName.mtw?name=a
    Line Number 1, Column 1:[{"name":"aaasdasdas","id":38,"author":"aa"},{"name":"aa","id":39,"author":"aa"},{"name":"aa","id":40,"author":"aa"},{"name":"aa","id":41,"author":"aa"}]
    ^

    What am I doing wrong?

     
    • aalmiray

      aalmiray - 2006-08-31

      Rubem,

      It seems to me that the output of the JSONArray is correct. When converting to a JSON string there is no use of any XML API. Is it possible that the problem may be in the servlet configuration ? what contentType is it suppoused to use ? text/plain ?

      Is another component on Mentawai's request processing hierarchy trying to interpret your servlet output as an XML string ?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.