private JsonDocument GenerateComplexJsonDocument2(string name) { var document = new JsonDocument(name, new List <KeyValuePair <string, FieldType> >() { new KeyValuePair <string, FieldType>("name1", FieldType.String), new KeyValuePair <string, FieldType>("name2", FieldType.String) }); document.CreateProperty("_document.data2"); document["_document.data2"]["name1"] = "value1"; document["_document.data2"]["name2"] = "value2"; document.CreateProperty("_document.moreData"); document["_document.moreData"]["name1"] = "value1"; document["_document.moreData"]["name2"] = "value2"; return(document); }
private JsonDocument GenerateJsonDocument(string name) { var document = new JsonDocument(name, new List <KeyValuePair <string, FieldType> >() { new KeyValuePair <string, FieldType>("name", FieldType.String) }); document.CreateProperty("_document.data"); document["_document.data"]["name"] = "value"; return(document); }
private JToken AnalyzeNode(JProperty node, JsonDocument document, CompareConfigDocument config, string paddingString) { if (!node.HasValues) { return(null); } var path = GetThePath(node.Path, paddingString, config.PropertyNodesName); if (node.Value.Type == JTokenType.Object) { if (!config.PropertyNodesName.Contains(node.Name)) { document.CreateProperty(path); foreach (var fieldInfo in config.FieldInfos) { document[path][fieldInfo.FieldName] = fieldInfo.DefaultValue.ToString(); } } return(node.Value); } else if (node.Value.Type == JTokenType.Array) { return(node.Value); } else if (supportJTokenTypes.Values.Contains(node.Value.Type)) { path = path.Replace($".{node.Name}", ""); var info = config.FieldInfos.FirstOrDefault(fieldInfo => fieldInfo.FieldName.Equals(node.Name)); if (info == null) { return(null); } if (info.NeedReplace && info.ReplaceValue.ToString().Equals(node.Value.ToString())) { document[path].UpdateValue(node.Name, info.DefaultValue.ToString()); } else if (supportJTokenTypes[info.FieldType] == node.Value.Type) { document[path].UpdateValue(node.Name, node.Value.ToString()); } } return(null); }