public static JsonElement FromJson (JsonElement parent, JsonObject json, object data) { if (json == null) return null; var title = GetString (json, "title") ?? ""; var group = GetString (json, "group"); var url = GetString (json, "url"); var radioSelected = GetString (json, "radioselected"); JsonElement root; if (group == null){ if (radioSelected == null) root = new JsonElement (title, url); else root = new JsonElement (title, new RadioGroup (int.Parse (radioSelected)), url); } else { if (radioSelected == null) root = new JsonElement (title, new Group (group), url); else { // It does not seem that we group elements together, notice when I add // the return, and then change my mind, I have to undo *twice* instead of once. root = new JsonElement (title, new RadioGroup (group, int.Parse (radioSelected)), url); } } root.jsonParent = parent; root.LoadSections (GetArray (json, "sections"), data); return root; }