我想在JSON文件中存储一些sql字符串。 这就是JSON文件在我的理想世界中的样子
getY()
明显的限制是JSON和javascript不支持多行字符串。
我想避免这样做:
double x = point1.getX();
double y = point2.getY();
我看到一个人这样做了,这也不理想:
[
"select t.index1, t.title, t.description, t.insertDate
from myTable t
join anotherTable t2 on t.index1 = t2.fIndex
where t2.active = 1",
...
]
然后在他的翻译程序中,他使用了[
"select t.index1, t.title, t.description, t.insertDate\nfrom myTable t\njoin anotherTable t2 on t.index1 = t2.fIndex\nwhere t2.active = 1",
...
]
。
我想知道是否有人为此目的有任何关于模板字符串工作(或计划在将来工作)的信息,如下所示:
[
["select t.index1, t.title, t.description, t.insertDate",
"from myTable t",
"join anotherTable t2 on t.index1 = t2.fIndex",
"where t2.active = 1"],
...
]
注意我在ES6的模板文字中使用了反引号(myMultilineStringInArrayForm.join("\n")
),显然变量的插值对于存储的JSON不起作用,但是这个文字的多行特征是我感兴趣的。
请注意,此问题类似于这个6岁的问题:Multiline strings in JSON
我再次问,因为我想知道[
`select t.index1, t.title, t.description, t.insertDate
from myTable t
join anotherTable t2 on t.index1 = t2.fIndex
where t2.active = 1`,
...
]
语法是否已经计划好或者已经有效了。
感谢您对此的帮助
答案 0 :(得分:0)
看起来我拥有可读存储格式的最佳选择是XML。我试图远离XML,并认为由于`
语法,JSON将来会有多行字符串,但没有