I am using JavaScriptSerializer for serializing objects to the file to the JSON format. But the result file has no readable formatting. How can I allow formating to get a readable file?
相关问题
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Generic Generics in Managed C++
- How to Debug/Register a Permanent WMI Event Which
I also wanted to be able to have formatted JSON without relying on a third-party component. Mark Lakata's solution worked well (thanks Mark), but I wanted the brackets and tabbing to be like those in Alex Zhevzhik's link. So here's a tweaked version of Mark's code that works that way, in case anyone else wants it:
Here's my solution that does not require using JSON.NET and is simpler than the code linked by Alex Zhevzhik.
and here is the formatter
You could use JSON.NET serializer, it supports JSON formatting
Yon can download this package via NuGet.
It seemed to be that there is no built-in tool for formatting JSON-serializer's output.
I suppose the reason why this happened is minimizing of data that we send via network.
Are you sure that you need formatted data in code? Or you want to analize JSON just during debugging?
There is a lot of online services that provide such functionality: 1, 2. Or standalone application: JSON viewer.
But if you need formatting inside application, you can write appropriate code by yourself.