In Delphi XE2, I need to make a function that receives a JSONValue
and returns an indented String
, much like JSONLint. This JSONValue could be any type of JSON, could be an array, an object, even just a string, so I have to make sure to cover all types with this function. I have no idea where to start.
相关问题
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Is there a Delphi 5 component that can handle .png
- Is there a way to install Delphi 2010 on Windows 2
相关文章
- json_encode 没有把数组转为json
- Livy Server: return a dataframe as JSON?
- Unexpected end of JSON input from an ajax call
- How do I do a nested list (array) of schema refere
- iconv() Vs. utf8_encode()
- Convert C# Object to Json Object
- LINQ .Include() properties from sub-types in TPH i
- How to make a custom list deserializer in Gson?
I have adopted the code from Mason, did the reader exercise, and put it in a separate unit:
To augment the answer by Doggen and Wheeler, I replaced the PrettyPrintArray routine with the following replacement in order to make sure that array objects are separated by commas otherwise the prettyprint output is invalid json.
You'll have to do it recursively. Something like this:
This covers the basic principle. WARNING: I wrote this up off the top of my head. It may not be correct or even compile, but it's the general idea. Also, you'll have to come up with your own implementation of printing a JSON array. But this should get you started.