我正在尝试使用以下格式从文本文件中创建JSON对象:
[query]
query1 = SELECT * FROM TBL
query2 = SELECT * FROM VIEWS
[process]
process1 = exec tree
process2 = exec four
我如何使它像这样:
[
{query :{
query1 : select * from tbl,
query2 : select * from views},
{
process : {process1 : exec tree, prcoess2: exec four
}
]
jQuery代码:
$(document).ready(function() {
$.ajax({
url: "file.ini",
dataType: "text",
success: function(r) {
var $txt = r.split("\n") $.each($txt, function() {
if (this.length > 0) {
if (this.match(/[[]]/g) != null) {}
}
});
},
error: function(r) {
console.log(r.responseText);
}
});
});