Reading JSON from a txt file

How to read the JSON from a txt file and parse it to Json object

This is really simple. A custom code for the same.

Just pass the path in which the json is stored. This method will read and return you a Jobject.

public static JObject LoadJSON(string filePath) {
          var json = "";
          using (var r = new StreamReader(filePath)) {
              json = r.ReadToEnd();
          }

          var sourceObject = JObject.Parse(json);
          return sourceObject;
      }
  }

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *