Hi Chetan,
Check these pages about export mappings. When you use message definition you will probably have to enter a list of the entity you want to convert to JSON in the export mapping activity in your microflow.
https://docs.mendix.com/refguide/export-mappings
Chetan,
I've done this before when exposing a POST API with the rest module.
This was my json I was creating
This was the export mapping I created
This was my domain model
and here is the microflow I used to create the objects for the export mapping activity
I shared my microflow to the model share if you want to take a look. I created this awhile back in a test project.
https://modelshare.mendix.com/models/3a402158-7fdb-40b0-924c-8e40195abbc1/example-api-that-returns-a-list