static string JsonNetMergToJson(Enums.PointMode pm, Dictionary <int, Dictionary <int, Vector3> > points) { StringBuilder sb = new StringBuilder(); JObject j = new JObject(); JObject groupjobject = new JObject(); foreach (KeyValuePair <int, Dictionary <int, Vector3> > item in points) { JObject pointsjobject = new JObject(); string groupstr = NumberToChar(item.Key + 1); foreach (KeyValuePair <int, Vector3> it in item.Value) { string indexstr = it.Key.ToString(); var jx = new JProperty("x", it.Value.x); var jy = new JProperty("y", it.Value.y); var jz = new JProperty("z", it.Value.z); JProperty pointproper = new JProperty(indexstr, new JObject(jx, jy, jz)); pointsjobject.Add(pointproper); } JProperty groupproper = new JProperty(groupstr, new JObject(pointsjobject)); groupjobject.Add(groupproper); } JProperty jend = new JProperty(pm.ToString(), groupjobject); j.Add(jend); Debug.Log(j.ToString()); // ParseJsontoDic(j.ToString()); return(j.ToString()); }
static string MergToJson(Enums.PointMode pm, Dictionary <int, Dictionary <int, Vector3> > points) { StringBuilder sb = new StringBuilder(); sb.Append("{\"" + pm.ToString() + "\":{"); foreach (KeyValuePair <int, Dictionary <int, Vector3> > item in points) { string abc = Tool.NumberToChar(item.Key + 1); sb.Append("\"" + abc + "\":{"); foreach (KeyValuePair <int, Vector3> it in item.Value) { Vector3 v = it.Value; int index = it.Key; sb.Append("\"" + index.ToString() + "\":{\"x\":" + v.x.ToString() + ",\"y\":" + v.y.ToString() + ",\"z\":" + v.z.ToString() + "},"); } sb.Remove(sb.Length - 1, 1); sb.Append("},"); } sb.Remove(sb.Length - 1, 1); sb.Append("}}"); return(sb.ToString()); }