Ravi Birla

Ravi Birla

  • NA
  • 292
  • 19.9k

Convert string List data to json format

Aug 11 2017 3:00 AM
Hello Everyone
 
I need your help. I'm working on windows service on 4.0 version using c# i want to convert string list to json format and pass that json data to third party.
 
My code  is:-  
 
List msisdnlist = new List();
msisdnlist.Add(rdr.GetInt64(0).ToString());
var jsonSerialiser = new JavaScriptSerializer();
var result = jsonSerialiser.Serialize(msisdnlist);
 
 and also try this one:-
 
 //var result = Newtonsoft.Json.JsonConvert.SerializeObject(msisdnlist);
//var result = JsonConvert.SerializeObject(msisdnlist); 
 
now my problem is i'm not gatting the data in correct format and how to pass that data to third party.
 
 data format which i'm gatting is-
["919464522803","919445453803"]
 
but i want this format -
{"msisdn": ["9418451354", "9617853673"]} 
 
Please Help me.

Answers (6)