How to check if the json is successfully parsed ?

3 posts, 0 answers
  1. lff
    lff avatar
    3 posts
    Member since:
    Mar 2019

    Posted 05 Mar Link to this post

    Hi 

    Now I am running with

    var oJSON = Newtonsoft.Json.JsonConvert.DeserializeObject(oS.GetRequestBodyAsString());
    var t = oJSON.JSONObject["target"]

    ........

    But sometimes the oS.GetRequestBodyAsString() is not a valid json string.

    Is there any way to check the oJSON status to see if the job is done without errors?

    For example,

    var oJSON = Newtonsoft.Json.JsonConvert.DeserializeObject(oS.GetRequestBodyAsString());

    if (!oJSON.isSuccessful) {

        // process error and return

  2. lff
    lff avatar
    3 posts
    Member since:
    Mar 2019

    Posted 05 Mar in reply to lff Link to this post

    Sorry the above was my test code (does not work). It should be

    var oJSON = Fiddler.WebFormats.JSON.JsonDecode( oS.GetRequestBodyAsString());

  3. lff
    lff avatar
    3 posts
    Member since:
    Mar 2019

    Posted 05 Mar in reply to lff Link to this post

    Seems to find out:

    if (oJSON.JSONObject == null) {
        // process error and return

Back to Top