Skip to main content

I am converting geodatabase data to JSON and using the HTTPCALLER to upload to an API. The JSON output from FME is adding square brackets[] as the first set of brackets but the API is looking for curly brackets{}. Is there a way for FME to output curly brackets instead of square brackets?

The API is also looking for some additional text between the first and second open brackets. Can I insert additional text between the brackets in the JSON output?

For example the FME JSON Writer is writing [{json text}] but the API is looking for {site:{json text}}

 

Thanks, David

Hi @dkirouac​ ,

 

The JSON writer will always output features as an array of JSON objects, that is, enclose them in square brackets. If you'd like the JSON to be formatted another way I'd suggest using the JSONTemplater Transformer to create the JSON string as you require and then write this out to TEXT so it does not get altered in any way.

 

Check out the article Writing JSON with JSONTemplater to learn more and see an example.


Hi @dkirouac​ ,

 

The JSON writer will always output features as an array of JSON objects, that is, enclose them in square brackets. If you'd like the JSON to be formatted another way I'd suggest using the JSONTemplater Transformer to create the JSON string as you require and then write this out to TEXT so it does not get altered in any way.

 

Check out the article Writing JSON with JSONTemplater to learn more and see an example.

Thanks Holly. I will check out the JSON Templater.


Hi @dkirouac​ ,

 

The JSON writer will always output features as an array of JSON objects, that is, enclose them in square brackets. If you'd like the JSON to be formatted another way I'd suggest using the JSONTemplater Transformer to create the JSON string as you require and then write this out to TEXT so it does not get altered in any way.

 

Check out the article Writing JSON with JSONTemplater to learn more and see an example.

I am able to use the JSON Templater to format the JSON as needed. I need to upload the JSON to an API using the HTTPCALLER. Is it possible to upload the JSON directly from the JSON Templater to the HTTPCALLER or do I need to physically create a JSON file and then upload the JSON file?

 

Thanks, David


Hi @dkirouac​ ,

If you would like to upload a JSON document stored in a feature attribute (e.g. called "_result") as the body of a POST request, you can set the attribute to the Upload Body parameter in the HTTPCaller.

 

httpcaller-parameters-example 


Hi @dkirouac​ ,

If you would like to upload a JSON document stored in a feature attribute (e.g. called "_result") as the body of a POST request, you can set the attribute to the Upload Body parameter in the HTTPCaller.

 

httpcaller-parameters-example 

That works. Thank you Takashi.


Reply