1234567891011121314151617181920212223242526272829303132 |
- using System;
- using Newtonsoft.Json.Linq;
- namespace jsonapi.Library
- {
- public class JsonFileReader
- {
- public static JsonFileReader GetInstance()
- {
- return new JsonFileReader();
- }
- public dynamic Read(string filePath)
- {
- string text;
- try
- {
- text = System.IO.File.ReadAllText(filePath);
- var json = JObject.Parse(text);
- return json;
- }
- catch (Exception e)
- {
- Console.Error.WriteLine(ConsoleColors.Red);
- Console.Error.WriteLine("There was an error parsing " + filePath + ": ");
- Console.Error.WriteLine(e);
- Console.Error.WriteLine(ConsoleColors.White);
- throw e;
- }
- }
- }
- }
|