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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
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 ?