Skip to main content

Hi,

I am new to JSON and I am trying to convert a JSON to a flat FME table.

In the workbench attached, I found a way, but I was wondering if there is a more

simple way.

My second question is: is there a way to convert this to a flat table without knowing the object attribute keys?

 

Jasper

The first JsonFlattener transformer should give you all the available attributes.

But the attributes will not be visible until you expose them, using the "Attributes to Expose" option in the settings of the transformer. (And yes, that will require typing the attribute names as FME does not know at this point what the attributes will be).

Hope this helps.


I would use the regular JSON reader with this parameters setting.


Thank you both!


I would use the regular JSON reader with this parameters setting.

One new question. When I want to use this workbench with a new json file, which contains one extra attribute, is it possible to get this extra attribute added correctly?

I enabled the "Merge Feature Type" (dynamic workflow), but since the schema was allready defined by the first json, the extra attribute is not added.


I would use the regular JSON reader with this parameters setting.

0684Q00000ArK38QAF.png

The reader can read every attribute from any JSON document as long as its schema fits to the JSON Query you have set to the reader parameter (below), even if it contains extra attributes.

jsona"collection"]
  • The extra attributes could be read definitely. You can see them with the Feature Information window in FME Data Inspector if you send the features to Inspector and run the workspace. However, those attributes won't be exposed on the Workbench Canvas automatically. I think that's the situation you have observed.

    A possible workaround is to use the AttributeExposer to manually expose all attributes that could be contained by JSON documents you need to handle. 


    The reader can read every attribute from any JSON document as long as its schema fits to the JSON Query you have set to the reader parameter (below), even if it contains extra attributes.

    jsona"collection"]
  • The extra attributes could be read definitely. You can see them with the Feature Information window in FME Data Inspector if you send the features to Inspector and run the workspace. However, those attributes won't be exposed on the Workbench Canvas automatically. I think that's the situation you have observed.

    A possible workaround is to use the AttributeExposer to manually expose all attributes that could be contained by JSON documents you need to handle. 

    Is there a way to get these extra attributes in the ouput, without

    having an understanding of all possible attributes?

     

    because it's possible that some of the future files will have slightly different

    attribute names "attribute1" <> "attribute_1". So it could be hard to identify all

    possible attributes to list in the Exposer.

     


    Reply