Skip to main content

Hi,

I have a dataset with an attribute containing a JSON file for every feature. The dataset also has an attribute called frequency. I'd like to add the key frequency to the JSON file, with the value in the frequency attribute. I tried using the JSONUpdater transformer:

Update Type: Insert into Object

 

JSON path: json

 

Object/Array index: frequency

 

Value Type: Plain Text

 

Value: uthe value of the frequency attribute]

The resulting JSON file has a key frequency with a string of length 0 as a value.

I also tried:

Update Type: Insert into Object

 

JSON path: json

 

Object/Array index: frequency

 

Value Type: JSON/XQuery

 

Value: fme:get-attribute("frequency")

This time the result was a key frequency with a value of null.

 

How do I resolve this?

The value type should be plain text, and the value should just point to the attribute.

The following works fine for me.

Just to verify, you are attaching the feature to both the Document and Update ports?


The value type should be plain text, and the value should just point to the attribute.

The following works fine for me.

Just to verify, you are attaching the feature to both the Document and Update ports?

I hadn't connected the feature to the Update port. Connecting it however doesn't solve my problem. The processing time increases very much. But that isn't the biggest problem. For most of the features, the frequency key in the JSON file doesn't have the right value.

 

 

I have 217 features in my dataset. I think the frequency key in the JSON file is now updated 217 times *for every feature*. After running the workspace, all JSON files seem to have the same value for frequency, namely that of the frequency attribute in the last feature that was processed.

 

 


@jdh got me thinking: maybe I should use the 'Group Update Features By' parameter? I'll give it a try.


I hadn't connected the feature to the Update port. Connecting it however doesn't solve my problem. The processing time increases very much. But that isn't the biggest problem. For most of the features, the frequency key in the JSON file doesn't have the right value.

 

 

I have 217 features in my dataset. I think the frequency key in the JSON file is now updated 217 times *for every feature*. After running the workspace, all JSON files seem to have the same value for frequency, namely that of the frequency attribute in the last feature that was processed.

 

 

If you have multiple features and you want each feature to be treated individually, you need to set the group by, on a unique attribute for each feature.
If you have multiple features and you want each feature to be treated individually, you need to set the group by, on a unique attribute for each feature.
You are right! It works fine now. Thank you!

 

 


Reply