[英]Print JSON with “pretty” (indented) format
If I create a JSON object and print it on the console: 如果我创建一个JSON对象并在控制台上打印它:
LJSONObject:= TJSONObject.Create;
LJSONObject.AddPair(TJSONPair.Create(TJSONString.Create('Hello'), TJSONString.Create('World')));
LJSONObject.AddPair(TJSONPair.Create(TJSONString.Create('Ciao'), TJSONString.Create('Mondo')));
Writeln(LJSONObject.ToString);
the result is: 结果是:
{"Hello":"World", "Ciao":"Mondo"}
How I can print the result with nicer indentation, like this? 我怎么能用更好的缩进打印结果,像这样?
{
"Hello":"World",
"Ciao":"MOndo"
}
TJSONObject
does not support pretty printing. TJSONObject
不支持漂亮的打印。
Other JSON libraries do. 其他JSON库也可以。 For instance SuperObject , as discussed here: How do I pretty-print JSON in Delphi? 例如SuperObject ,如下所述: 如何在Delphi中打印JSON?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.