Skip to main content

Hi,

I am writing out to a json writer and intend to stream this json using fme cloud.

0684Q00000ArD5bQAF.png

The output looks like 

i
{
"STAGING_ID" : "9515",
"USER_API" : "A2C3601C-40E9-48DC-A0C0-5D4DB0867A2E",
"REQUEST_GUID" : "80318a93-f513-4e63-8c08-9e07250af0e2",
"ID" : "120654",
"UNIQUE_LOCATION_ID" : "5819",
"UNIQUE_SAMPLE_ID" : "576683",
"ROW_CREATED_DATE" : "18/05/2010",
"LAST_EDITED_DATE" : "18/08/2017",
etc

Ideally I would like to add a few lines before the records return e.g.

b
    "status":"ok", 
    "body" : 
{
"STAGING_ID" : "9515",
"USER_API" : "A2C3601C-40E9-48DC-A0C0-5D4DB0867A2E",
"REQUEST_GUID" : "80318a93-f513-4e63-8c08-9e07250af0e2",
"ID" : "120654",
"UNIQUE_LOCATION_ID" : "5819",
"UNIQUE_SAMPLE_ID" : "576683",
"ROW_CREATED_DATE" : "18/05/2010",
"LAST_EDITED_DATE" : "18/08/2017",

Could anyone suggest how this can be achieved. I really don't want to manually template the output from the rows because they are dynamic and remove any null values.

Many Thanks,

Oliver

Hi @olivermorris, a possible way is: write the JSON document above with the FeautreWriter (Format: JSON), read back the resulting document with the FeatureReader (Format: Text File, Read Whole File At Once: Yes), extract the "body" { contents of body } with the JSONFragmenter, finally create your desired JSON object {"status" : "ok", "body" : { contents of body }} with the JSONTemplater.


Reply