How to set up JOSN string transfer

code show as below

New new SW = the StringWriter the StringWriter ();
the using (JSONWriter JW = new new JsonTextWriter (SW))
{
       JW.Formatting = Formatting.Indented;
     //JW.WriteStartArray (); // this is a start symbol set
     //JW.WriteEndArray (); // this is the end for the collection of symbols
     JW.WriteStartObject (); // this is an object start symbol
     JW.WritePropertyName ( "merchantId"); // json field names
     JW.WriteValue (merchantId); / / JSON corresponding data fields

     JW.WritePropertyName("TransType");
     JW.WriteValue("");

     JW.WritePropertyName("ClientId");
     JW.WriteValue("");

     JW.WritePropertyName("StoreId");  
     JW.WriteValue("");

     JW.WritePropertyName("StartTransDateTime");
     JW.WriteValue(DateTime.Now.AddMonths(-3).ToString("yyyy/MM/dd HH:mm:ss"));

     JW.WritePropertyName("EndTransDateTime");
     JW.WriteValue(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));

     JW.WritePropertyName("ConsumerId");
     JW.WriteValue(model.member_id);

     JW.WriteEndObject (); // this is a start symbol object
     JW.Flush ();
     sw.Close ();
}

 Console.WriteLine(sw.GetStringBuilder().ToString() );

 

If better, or have questions, please comment below, I could only hope to help to help you.

Guess you like

Origin www.cnblogs.com/leon1/p/11302688.html