Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Unable to get proper data from JsonConvert.DeserializeObject

$
0
0

Rest Api returns the following string which I got in the immediate window of visual studio.
"{\"status1\":1,\"odSequenceID1\":15,\"status_message1\":\" Record Added successfully - Op Master ! \",\"status2\":1,\"odSequenceID2\":15,\"status_message2\":\"Record Added Successfully - Op Details ! \"}"

I assigned this string to the responseJson variable. Then I used the following code yet I am not able to get the oSequenceID
other data is properly returned properly.
Code

var postresponse = new PostResponse();
if (responseJson != "")
{
postresponse = (JsonConvert.DeserializeObject(responseJson));

                 if (CHK.Vld(postresponse.oSequenceID1) != "NA")
                        App.opermasterOSequenceNo = (int)postresponse.oSequenceID1;
                    else
                        App.opermasterOSequenceNo = 0;

            } //if (responseJson != "")

Immediate output of postresponse as follows
{LCAPP.Models.JsonModel.PostResponse}
oSequenceID1: 0 (I WANT THE Value 15 from string above responseJson)
oSequenceID2: 0
status1: 1
status2: 1
status_message1: " Record Added successfully - Op Master ! "
status_message2: "Record Added Successfully - Op Details ! "
Models JsonModel as follows
[JsonObject]
public class PostResponse
{
public int status1{ get; set; }
public int oSequenceID1 { get; set; }
public string status_message1 { get; set; }
public int status2 { get; set; }
public int oSequenceID2 { get; set; }
public string status_message2 { get; set; }
}
Following is the data from Postman (JSON option)
{
"status1": 1,
"odSequenceID1": 15,
"status_message1": " Record Added successfully - Op Master ! ",
"status2": 1,
"odSequenceID2": 15,
"status_message2": "Record Added Successfully - Op Details ! "
}
I have spent hours to avail. Request your help in this. Some one please go thru this.
Thanks


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>