MARS-Curiosity: using JsonDataObjects

One of the key aspect I wanted to achieve while designing the MARS-Curiosity REST library was not to tie the developer to a specific implementation or library used in MARS-Curiosity.

For example, one may want to use a specific ORM / DAC library / JSON library for many different reasons (like performance, functionalities, uniformity with respect to the whole codebase of the project).

Given Andreas Hausladen has released a nice (easy to use) and performant JSON library (faster than built-it System.JSON library) named JsonDataObjects, I wanted to provide an example of how easy it is to plug such a library into MARS-Curiosity.

Using JsonDataObjects in MARS-Curiosity

As you can see in the first screenshot, here above, you can simply use JsonDataObjects data types (TJsonObject, TJsonArray, …) as result values and/or arguments of your resources methods.

MARS-Curiosity will try to find a way to properly serialize those types according to the client’s request. This is done through a MessageBodyReader and a MessageBodyWriter implementation (you can find them in MARS.JsonDataObjects.ReadersAndWriters.pas unit).

Reader and Writer implementation needed to plug JsonDataObjects into MARS-Curiosity

So basically you only need to include the MARS.JsonDataObjects.ReadersAndWriters.pas unit in your uses list and you can start using JsonDataObjects in your REST application server written with MARS-Curiosity.

Kudos to Andreas for the great JsonDataObjects library. 🙂

Enjoy

Andrea

PS: I am going to do the same thing using the Grijjy library (that has serialization/deserialization and BSON support as a plus!)

One thought on “MARS-Curiosity: using JsonDataObjects

  1. Holger Flick says:

    Great! Thanks for comparing these libraries!

Leave a Reply

Your email address will not be published. Required fields are marked *