private static async Task <object> CreateObjectFromJsonAsync(string jsonStr) { object obj = null; try { // obj = MiniJsonParser.DEFAULT_INSTANCE.parse(jsonStr); obj = await StaticJsonParser.ParseAsync(jsonStr); } catch (JsonParserException e) { throw new Exception(e.Message, e); } return(obj); }
// Note: Conceptually, it is a method "defined" in JsonParseable. // Since you cannot inherit this implementation in subclasses, // each subclass, or any class that implements JsonParseable, should have its own implementation of FromJson(). // Use this class as an example.... if necessary... // (but, this is a rather strange implementation...) // (normally, each specific field of a JsonParseable class should be initialized by the corresponding values in jsonStr, // and it's rather hard to Create a "generic" implementation, unless you use reflection, etc.) public static async Task <JsonParseable> FromJsonAsync(string jsonStr) { BaseJsonWrapper jsonParseable = null; try { // Object obj = MiniJsonParser.DEFAULT_INSTANCE.parse(jsonStr); object obj = await StaticJsonParser.ParseAsync(jsonStr); jsonParseable = new BaseJsonWrapperAnonymousInnerClass(obj); } catch (JsonParserException e) { throw new Exception(e.Message, e); } return(jsonParseable); }