Is there any easy way to parse below JSOn in c#
{"type":"text","totalprice":"0.0045","totalgsm":"1","remaincredit":"44.92293","messages": [
{"status":"1","messageid":"234011120530636881","gsm":"923122699633"}
]}
and in case Multiple results.
Is there any easy way to parse below JSOn in c#
{"type":"text","totalprice":"0.0045","totalgsm":"1","remaincredit":"44.92293","messages": [
{"status":"1","messageid":"234011120530636881","gsm":"923122699633"}
]}
and in case Multiple results.
I found a way to get it without using any external API
Follow these steps:
Newtonsoft.Json
library to your project using the Nuget Package Manager;Convert the JSON received from your service using this code:
(Feel free to rename
RootObject
to something more meaningful to you. The other classes should remain unchanged.)For me ... the easiest way to do that is using JSON.net do a deserialize to a entity that represents the object, for example:
And do this:
You can safely use built-in
JavaScriptSerializer
without referencing additional third party libraries: