Hi @oumar, you can use the JSONTemplater to convert the CSV record to a JSON text structure. This is a template expression example that convert a single row of the CSV to a JSON text.
{
"logging" : {
"sessionId" : fme:get-attribute("logging.sessionId"),
"quoteNumber" : fme:get-attribute("logging.quoteNumber")
},
"quote" : {
"numberOfUnits" : fme:get-attribute("quote.numberOfUnits"),
"numberOfResidents" : fme:get-attribute("quote.numberOfResidents"),
"numberOfDogs" : fme:get-attribute("quote.numberOfDogs"),
"numberOfGarages" : fme:get-attribute("quote.numberOfGarages")
},
"filter" : {
"formCode" : fme:get-attribute("filter.formCode"),
"uwCompany" : fme:get-attribute("filter.uwCompany"),
"uwTier" : fme:get-attribute("filter.uwTier"),
"wildfireScore": fme:get-attribute("filter.wildfireScore")
}
}
See also the Help to learn more.
https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/jsontemplater.htm
Hope this helps.
Hi @oumar,
You can use the JSONTemplater to create the output JSON that can be used in the JSON writer. I am attaching a workspace to illustrate.
csv2json.fmw
Thanks Dave and Takashi for your expertise.
Hi @oumar,
You can use the JSONTemplater to create the output JSON that can be used in the JSON writer. I am attaching a workspace to illustrate.
csv2json.fmw
Hi Dave,
on a follow up question, how do I feed the result into a HTTPCaller to call an API. I am able to do so just by having only 1 record in a file using Upload data = file and pointing that file with single record.CL_Underwriter_JsonExtracter_Grid_Input_json.fmwt
Hi Dave,
on a follow up question, how do I feed the result into a HTTPCaller to call an API. I am able to do so just by having only 1 record in a file using Upload data = file and pointing that file with single record.CL_Underwriter_JsonExtracter_Grid_Input_json.fmwt
Hi @oumar,
If you use Takashi's template in a single JSONTemplater, you will get one attribute containing the complete JSON string, that can be used as the upload string in the HTTPCaller.