How to use Fiddler.WebFormats.JSON.JsonDecode

4 posts, 0 answers
  1. Arnaud
    Arnaud avatar
    2 posts
    Member since:
    Apr 2014

    Posted 08 Apr 2014 Link to this post


    I have a JSON string and I want to parse it to an object (to do some query after that).
    I have found Fiddler.WebFormats.JSON.JsonDecode() but the returned JSONObject has no method to get or set content.

    How to decode and use JSON strings ?

    Thanks for any help !
  2. Eric Lawrence
    Eric Lawrence avatar
    832 posts

    Posted 08 Apr 2014 Link to this post

    Hello, Arnaud--

    The returned object has a JSONObject property which is an ArrayList, Hashtable, or primitive value that is equivalent to the json object in question. Fiddler uses this class in its JSONView extension.

    If you prefer a different pattern (e.g. something with strong typing, a schema, etc) then you can & should use one of the myriad JSON encoder/decoders available for the .NET Framework.

    Eric Lawrence

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. Arnaud
    Arnaud avatar
    2 posts
    Member since:
    Apr 2014

    Posted 09 Apr 2014 in reply to Eric Lawrence Link to this post

    Hello Eric,

    Thanks for your quick answer. My wrong was to miss JSONObject and its meaning.
    I post my test case (in FiddlerScript) in case someone has the same question:

    var sInput = '{"a" : 1, "b" : [2, 3, 4]}';
    var oJSON = Fiddler.WebFormats.JSON.JsonDecode(sInput);
    FiddlerApplication.Log.LogFormat('input: {0}', sInput);
    FiddlerApplication.Log.LogFormat('oJSON: {0}', oJSON.ToString());
    FiddlerApplication.Log.LogFormat('oJSON["a"]: {0} (expected: 1)', oJSON.JSONObject["a"]);
    FiddlerApplication.Log.LogFormat('oJSON["b"] : {0} (expected: 2)', oJSON.JSONObject["b"][0]);

  4. 继隆
    继隆 avatar
    1 posts
    Member since:
    May 2018

    Posted 05 May 2018 in reply to Arnaud Link to this post

    Fiddler.WebFormats.JSON.JSONParseResult json = (Fiddler.WebFormats.JSON.JSONParseResult)Fiddler.WebFormats.JSON.JsonDecode(jsonst);
                        Hashtable ht = (Hashtable)json.JSONObject;
                  string value= ht["name"].ToString();
Back to Top