Skip to main content
Solved

json writer/stream

  • June 14, 2018
  • 1 reply
  • 12 views

oliver.morris
Contributor
Forum|alt.badge.img+14

Hi,

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

0684Q00000ArD5bQAF.png

The output looks like 

[
{
"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.

[
    "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

Best answer by takashi

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

takashi
Celebrity
  • 7843 replies
  • Best Answer
  • June 14, 2018

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.