There appears to be a few JSON options for Delphi out there - is there a recommended library for use with XE2? I'm looking for sharing of objects between Delphi XE2 and PHP web applications. (serialization and posting delphi objects in a compatible way for PHP web apps and de-serialization from a restful PHP call to delphi server side)
6 Answers
JSON support* is included in XE2 (and XE). JSON
See this thread in SO for a link to a paper by Marco, explaining use of JSON and restful implementations.
REST Servers in Delphi XE Using DataSnap
- Note : This is valid for the Enterprise and up version.
-
4D2010 has DBXJSON included too, but it is severely broken (see [note](http://stackoverflow.com/questions/6217595/json-parse-result-from-virustotal-api/6218635#6218635)) – Premature Optimization Oct 12 '11 at 06:08
I know of two libraries.
The built in library and Super Object.
I use Super Object as it's really easy to use.

- 14,263
- 7
- 55
- 58

- 12,447
- 2
- 48
- 80
Unlike XML libraries (OmniXML, NativeXml) lkJSON does not provide methods to serialize TObject / TPersistent instances using RTTI directly, it requires custom code to map the property values to a JSON object.
SuperObject support marshaling for Delphi 2010 and higher.

- 36,362
- 28
- 176
- 378
DWScript has a dwsJSON unit which implements a fast JSON parser & writer, it doesn't rely on RTTI/TPersistent but on mapping by custom code.

- 5,931
- 1
- 39
- 61
Open source delphi-oop library includes powerful serializer. It can use multiple backends (including native DBXJSON, superobject, NativeXml) and can serialize/deserialize almost anything. Some more information available in the project's wiki

- 5,485
- 1
- 25
- 35
Just for the record, there is one more JSON library, compatible with Delphi7+ and FPC.
It is side-project of mORMot and is speed-optimized (there were comparisons with SuperObject, though i don't recall the link)

- 15,799
- 35
- 62