Wednesday, May 4, 2016

json parsing

{"results":[
                {"errorCode":"28673","errorMsg":"Destination number not numeric"},
                {"errorCode":"28674","errorMsg":"Destination number empty"},
                {"errorCode":"28675","errorMsg":"Sender address empty"},
                {"errorCode":"28676","errorMsg":"SMS over 160 character, Non-compliant message"},
                {"errorCode":"28677","errorMsg":"UDH is invalid"},
                {"errorCode":"28678","errorMsg":"Coding is invalid"},
                {"errorCode":"28679","errorMsg":"SMS text is empty"},
                {"errorCode":"28680","errorMsg":"Invalid sender ID"},
                {"errorCode":"28681","errorMsg":"Invalid message, Duplicate message, Submit failed"},
                {"errorCode":"28682","errorMsg":"Invalid Receiver ID (will validate Indian mobile numbers only)"},
                {"errorCode":"28683","errorMsg":"Invalid Date time for message Schedule (If the date specified in message post for schedule delivery is less than current date or more than expiry date or more than 1 year)"}
                ]}



  var json = System.IO.File.ReadAllText(yourpath);
            //dynamic stuff = JsonConvert.DeserializeObject(json);
            JObject results = JObject.Parse(json);

            foreach (var result in results["results"])
            {
                string errorCode = (string)result["errorCode"];
                string errorMsg = (string)result["errorMsg"];
                Console.WriteLine(errorCode + ",,,....,,," + errorMsg);


            }

No comments:

Post a Comment