void Populate(JsonValue json, RootElement root, JsonValue data) { if (json.ContainsKey(Constants.Title)) { root.Caption = json[Constants.Title]; } JsonValue jsonRoot = null; try { jsonRoot = json[Constants.Root]; } catch (Exception) { Console.WriteLine("Bad JSON: could not find the root element - " + json.ToString()); return; } if (json.ContainsKey(Constants.DataRoot)) { var dataroot = json[Constants.DataRoot].CleanString(); if (data != null && data.ContainsKey(dataroot)) { data = data[dataroot]; } } foreach (JsonObject section in jsonRoot) { var sec = new FormSectionBuilder(this._controller).Build(section, data); foreach (var el in sec.Elements) { if (!string.IsNullOrEmpty(el.ID) && !_elements.ContainsKey(el.ID)) { _elements.Add(el.ID, el); } } root.Add(sec); } }
void Populate (JsonValue json, RootElement root, JsonValue data) { if (json.ContainsKey(Constants.Title)) root.Caption = json[Constants.Title]; JsonValue jsonRoot = null; try { jsonRoot = json[Constants.Root]; } catch (Exception){ Console.WriteLine("Bad JSON: could not find the root element - "+json.ToString()) ; return; } if (json.ContainsKey(Constants.DataRoot)){ var dataroot = json[Constants.DataRoot].CleanString(); if (data!=null && data.ContainsKey(dataroot)) data = data[dataroot]; } foreach (JsonObject section in jsonRoot){ var sec = new FormSectionBuilder(this._controller).Build(section, data); foreach (var el in sec.Elements) { if (!string.IsNullOrEmpty(el.ID) && !_elements.ContainsKey(el.ID)) _elements.Add(el.ID, el); } root.Add(sec); } }