我正在开发一个项目,该项目将用于帮助平台的未来开发人员分析和理解 JSON 数组。我正在引用 Facebook 出色的 Graph Explorer 页面,在此处看到,并希望将我们的数组输出为一个美化的、正确的制表符缩进和换行符数组,就像它在资源管理器上所做的那样。
数组被输出到 a textarea
,因此我认为我遇到了换行和制表符的问题。我也尝试过使用美化库,但没有运气。
例子:
{"outcome" : "success", "result" : {"name" : "messaging-sockets", "default-interface" : "external", "include" : [], "socket-binding" : {"messaging" : {"name" : "messaging", "interface" : null, "port" : 5445, "fixed-port" : null, "multicast-address" : null, "multicast-port" : null}, "messaging-throughput" : {"name" : "messaging-throughput", "interface" : null, "port" : 5455, "fixed-port" : null, "multicast-address" : null, "multicast-port" : null}}}, "compensating-operation" : null}
到:
{
"outcome":"success",
"result":{
"name":"messaging-sockets",
"default-interface":"external",
"include":[
],
"socket-binding":{
"messaging":{
"name":"messaging",
"interface":null,
"port":5445,
"fixed-port":null,
"multicast-address":null,
"multicast-port":null
},
"messaging-throughput":{
"name":"messaging-throughput",
"interface":null,
"port":5455,
"fixed-port":null,
"multicast-address":null,
"multicast-port":null
}
}
},
"compensating-operation":null
}