Skip to main content

Hello.

I have a JSON file the looks roughly like this, containing a list of un-named values:
{ > { “UniqueID”:123446,

      “Dealership”:”Dan’s Dodge”,

      “Owner”:”Dan”,

      “BestSelling”:

        e “blue”,

          “red”,

          “blue”,

          ...

          “red”

        ]

      ... 

      “Telephone”:”411”

    },

    ...

  ]

}

My first JSONFragmenter feeds two workflows: the first workflow captures the named values (including “UniqueID”), and the second workflow immediately discards everything but “UniqueID” and the JSON from the first JSONFragmenter and then uses a JSONFragmenter to turn the JSON list into Features.  Finally, a FeatureJoiner that adds to each newly-minted Feature an Attribute containing the appropriate name for its unnamed value.  Now it’s time to FeatureMerge the new Attributes back into the first workflow by matching on “UniqueID”.

Alas, the newly-assigned names are stored in the same Attribute of each JSON-list Feature.  So, after FeatureMerger merges the first Feature, the transformer’s Conflict Resolution decides whether to preserve the Attribute in the Requestor, or to overwrite it with each remaining Feature from the Supplier.

Is there a way, after turning the new Features into an FME list, to rename each Attribute (e.g. concatenate json_index from the JSON list to the Attribute name) while sending the Feature to a FeatureMerger or ListBasedFeatureMerger?

Hi ​@pbyhistorian thanks for your question! I was following your question in the first half, but I got lost around what’s actually happening to the FeatureMerger. Are you wanting to preserve all of the attributes from both workflows? If so, you may want to use an Aggregator instead with Group By set to your UniqueID and preserving your attributes by setting Accumulation Mode to Merge Incoming Attributes. You may also want to try the FeatureJoiner instead of the FeatureMerger for an alternative method. 

And, if none of these suggestions help - perhaps you can attach your workspace with a sample of your data so that I may investigate and see if there’s a workaround. 


Hello ​@evieatsafe.

Let’s say there are 10 UniqueIDs in the JSON file and each UniqueID has a JSON List with the same 100 elements.  The JSONFragmenter in the second workflow turns that JSON into 1,000 Features comprised of the Attributes UniqueID and Value (the nth element within that UniqueID’s JSON List).  The first workflow has but 10 Features, each containing the Attribute UniqueID.

The (smack-my-forehead) problem is that the JSONFragmenter splits a JSON List into Features.  The FeatureMerger for the two workflows adds to each of the 10 Requester Features the Value Attribute from the first of its 100 matching Supplier Features; that Value Attribute is then overwritten by the remaining 99 Supplier Features.  So I end up with just the last Value for each UniqueID.

What I needed, of course, was all 100 JSON List elements as Attributes on a Feature. I finally converted the 1,000 Features into an FME List and manually configured an AttributeCreator to map the 100 (many more, actually) FME List elements to Attribute names.

Configuring the AttributeCreator took two days and it apparently cannot handle Attribute changes dynamically (e.g. via a ValueName Attribute).  It would be great to hear a better way, but I had a deadline to meet.


Reply