请问这是什么数据结构,怎么把它转换为 json?

2019-03-16 22:49:50 +08:00
 ProximaCentauri

{ "root1" { "item1" "1" "item2" "abc"

	"item3"
	{
		"cell"
		{
			"cell1"
			{
				"cell1Name"	"99"
			}
			"cell2"
			{
				"cell2Name"	"cdb"
			}	
		}
	}
	
	"item4"	"valueI"
}

"root2"
{
	"item1"	"88"
	"item2"	"tg"
	
	"item3"
	{
		"cell"
		{
			"cell1"
			{
				"cell1Name"	"99"
			}
			"cell2"
			{
				"cell2Name"	"ujh"
			}
			
		}
	}
	
	"item4"	"valueb"
}

}

3262 次点击
所在节点    算法
9 条回复
ProximaCentauri
2019-03-16 22:56:49 +08:00
不知道用正则转换,该如何写
ProximaCentauri
2019-03-16 22:56:59 +08:00
这个结构太奇葩了
Trim21
2019-03-16 23:02:01 +08:00
感觉这是没有:和,的 json...
183shl
2019-03-16 23:15:02 +08:00
" "替换成 ":" "\n"替换成",\n" 这样??
CEBBCAT
2019-03-17 02:29:55 +08:00
既然都是字符串,用堆栈搞定吧
geelaw
2019-03-17 05:33:17 +08:00
随便瞎写的一个,大概十几分钟的功夫

https://gist.github.com/GeeLaw/6761e976a3ae6804084a7c24452e1357
geelaw
2019-03-17 05:34:02 +08:00
另外这个算不上什么“数据结构”,只是一种数据的序列化方式罢了
xl224
2019-03-17 10:17:05 +08:00
Tcl
cocacola
2019-03-18 12:16:28 +08:00

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/545359

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX