JsonTextWriter

Jun 14, 2010 at 2:36 PM

how to write with JsonTextWriter below output code;

 

------------

 

{"SearchResponse":
 {"NumResults":"15","Pagination":"page5","MinPrice":"14","MaxPrice":"315","Results":
  {"Result":[
  {"Id":"0","Name":"name1"},
  {"Id":"0","Name":"name2"}
  ]
  }
 }
}

---------

i tried this code but i am receiving error.

            jsonWriter.WriteStartObject();
            jsonWriter.WritePropertyName("SearchResponse");
            jsonWriter.WritePropertyName("NumResults");
            jsonWriter.WriteValue("");
            jsonWriter.WritePropertyName("Pagination");
            jsonWriter.WriteValue("");
            jsonWriter.WritePropertyName("MinPrice");
            jsonWriter.WriteValue("");
            jsonWriter.WritePropertyName("MaxPrice");
            jsonWriter.WriteValue("");
            jsonWriter.WritePropertyName("Results");
            jsonWriter.WritePropertyName("Result");
            jsonWriter.WriteStartArray();
            jsonWriter.WriteValue("0");
            jsonWriter.WritePropertyName("Id");
            jsonWriter.WriteValue("0");
            jsonWriter.WritePropertyName("Name");
            jsonWriter.WriteValue("name1");
            jsonWriter.WriteEnd();
            jsonWriter.WriteEndObject();

 

thanks