asp.net - Questions on passing and formatting JSON to HttpResponse -


I just wanted to clarify some questions to me that I am creating a JSON string and using context.response I am returning it. I'm just calling a URL to a .shx handler and trying to return to JSON.

Here's how I've contacted it yet:

List product = GetCarolProducts (); List images = new list ();

  foreach (product in product p) {string imageTag = string.format (@ "& lt; img src =" "{0}" "alt =" "" "& gt; Lt; / li & gt; ", Util. ImageRural (P. Image, Falls)); Images.Add (imageTag); I ++; } String jsonString = images.ToJSON (); Context.Response.Write (jsonString);  

I'm using the Example Assistant method here for JSON:

So my questions are:

1) I did not want to To really return the whole product object, I really did not want to give it back at all. I wanted to return a group of image tags created in my foreach loop, so what I did was just make that string in each instance of the product and add it to a new generic list type string. I think it's okay, and a normal string list can be serialized in JSON ... this string is an object, so should it be okay? The thing is, it is not going to be any asset, so I do not know. I think that if I'm going to work in such a way as if I want to pass some object as an example such as, for example, at least it has properties in it such as IDs, names, etc.

It's not going to work, I'm wondering how can I get back a list of JSON which gives me I believe that although I still have the key / value Must be able to reach back JSON But in terms of data, it needs all my jQuery, just a bunch of images.

So my question is, I pass ost to the object in which there is some parameters near Jason, in I, I picked up through jQuery because a nice type object for jQuery What makes you depend on those qualities? I do not think sending a normal string list will work in my situation.

So it's not sure how to set it and only the list of images to parsing my ToJSON helper method and ultimately for my jQuery JSON.

2) I'm sure there is a need to do something special to tell the context. The reaction is that it is helpful to pass the final string apart from JSON makes the method here? With XML, you have to give feedback to format it as XML with reference. Response. Contact Type = "Text / XML", do I need to specify something if I am passing JSON strings back?

For feedback content, type Douglas Crockford's proposal.

  Content-Type: Application / jsonrequest  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -