Esempio n. 1
0
 /// <summary>
 /// Loads class from a JSON string
 /// </summary>
 /// <param name="i">Loadable item</param>
 /// <param name="json">JSON string</param>
 /// <param name="ct">The token to monitor for cancellation requests</param>
 public static void LoadJSON(this ILoadableItem i, string json, CancellationToken ct = default)
 {
     i.Load(eduJSON.Parser.Parse(json, ct));
 }
Esempio n. 2
0
 /// <summary>
 /// Loads class from a JSON string provided by API
 /// </summary>
 /// <param name="i">Loadable item</param>
 /// <param name="json">JSON string representing a dictionary of key/values with <paramref name="name"/> element</param>
 /// <param name="name">The name of the value holder element</param>
 /// <param name="ct">The token to monitor for cancellation requests</param>
 public static void LoadJSONAPIResponse(this ILoadableItem i, string json, string name, CancellationToken ct = default)
 {
     // Parse JSON string and get inner key/value dictionary, then load data.
     i.Load(LoadJSONAPIResponse(json, name, ct)["data"]);
 }