TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mohan yadav
NA
198
723
Why JSON convert into javascript object.
Apr 14 2016 3:06 AM
I have created web api which return JSON like below web api methods return list of book class
public HttpResponseMessage GetAllBooks()
{
list.Add(new Book() { Id = 1, Name = "Book1", Price = 0 });
list.Add(new Book() { Id = 2, Name = "Book2", Price = 0 });
HttpResponseMessage ob = new HttpResponseMessage();
return Request.CreateResponse(HttpStatusCode.Created, list);
//return list;
}
When i call it from ajax call it returns in javascript object like
resultArray[2]
result[0].ID, result[0].Name, result[0].Price and so on.
I am expectiing JSON like
[
{
"Id": 1,
"Name": "Book1",
"Price": 0,
},
{
"Id": 2,
"Name": "Book1",
"Price": 0,
},]
for the same i have to use JSON.Stringfy in ajax call.
Is there a way to get above JSON directly from web api or WCF rest.
Reply
Answers (
4
)
How to bind image dynamically in html
how to maitaine page sate when back clicks using jquery