Last post May 13, 2013 09:15 AM by Vijay Patel
Member
229 Points
662 Posts
May 13, 2013 09:08 AM|ssvikramuk|LINK
Hi - Below code is perfectly working fine and output as json format.
Layout = null; var db = Database.Open("dbs"); var rows = db.Query(@"SELECT postingID, title, shortdescription, SUBSTRING(description, 1, 100) as description FROM Posting " + "LEFT OUTER JOIN Categories ON Posting.category = Categories.categoryID " + "WHERE Categories.categoryID = 1 ORDER BY Posting.postingID DESC"); Response.ContentType = "application/json"; Json.Write(rows, Response.Output); }
Result is
[{"PostingID":426,"title":" "}]
I would like to add "books" as a group for this json output. Example
{ "books": [{"PostingID":426,"title":" "}]}
Thanks
660 Points
147 Posts
May 13, 2013 09:15 AM|Vijay Patel|LINK
Try below code
Json.Write(new {books = rows}, Response.Output);
Member
229 Points
662 Posts
JSON output
May 13, 2013 09:08 AM|ssvikramuk|LINK
Hi - Below code is perfectly working fine and output as json format.
Result is
I would like to add "books" as a group for this json output. Example
Thanks
Member
660 Points
147 Posts
Re: JSON output
May 13, 2013 09:15 AM|Vijay Patel|LINK
Try below code