- Delphi Cookbook
- Daniele Spinetti Daniele Teti
- 123字
- 2025-04-04 16:22:46
Getting ready
JSON provides the following five datatypes—String, Number, Object, Array, Boolean, and Null.
This simplicity is an advantage when you have to read a JSON string into some kind of language-specific structure, because every modern language supports the JSON datatypes as simple types, or as a HashMap (in the case of JSON objects) or List (in the case of JSON arrays). So, it makes sense that a data format that is interchangeable with programming languages is also based on these types and structures.
Since version 2009, Delphi has provided built-in support for JSON. The System.JSON.pas unit contains all the JSON types with a nice object-oriented interface. In this recipe, you'll see how to generate, modify, and parse a JSON string.