Skip to main content

Hey,

I am fairly new to FME and I was recently using the MongoDB reader to read some data from Mongo, transform the data and write the same structure back to Mongo using the MongoDB writer, I get however a strange output while doing that.

The input structure looked something like that: "test" : [{"type" : "my_test"}], but when writing back to Mongo the output looks like that: "test" : ["{ \\"type\\" : \\"my_test\\" }"].

Could someone tell me what the problem might be?

Thank you very much in advance :)

Kathrin

Hi @kathrinkarer,

Could you be a bit more specific? How did you set up your writer output feature type? What is your "Document Source" setting? JSON Attribute or Feature?

It seems that the value of the "test" array has been escaped as a string somehow. This might have been caused by some transformer (e.g. JSONFormatter, PythonCaller), but I don't have a clue at this point what could be the reason.

Sander


Hi @kathrinkarer,

Could you be a bit more specific? How did you set up your writer output feature type? What is your "Document Source" setting? JSON Attribute or Feature?

It seems that the value of the "test" array has been escaped as a string somehow. This might have been caused by some transformer (e.g. JSONFormatter, PythonCaller), but I don't have a clue at this point what could be the reason.

Sander

Hey, I didn't change anything in the writer settings before.

 

I now tried it again, just reading and writing back to mongo without any transformers in between and using JSON Attribute as Document Source setting. Now the output looks like this "type" : "my_test", without any brackets. I would however like the structure to exactly look like it did in the input dataset. Furthermore, I have more information in the file, like for example coordinates, using the JSON Attribute as source setting, it didn't write that information back to mongo.

 

 


Hi @kathrinkarer,

 

Just checking: since you're also reading from MongoDB, you did properly set the Reader settings as well? Set Read Original JSON Document to Yes. Your whole JSON document will then be stored in the mongodb_json attribute. What happens if you write that back (using the Document Source attribute set to mongodb_json)? It should look exactly the same as before, I hope...

 


Hey, I didn't change anything in the writer settings before.

 

I now tried it again, just reading and writing back to mongo without any transformers in between and using JSON Attribute as Document Source setting. Now the output looks like this "type" : "my_test", without any brackets. I would however like the structure to exactly look like it did in the input dataset. Furthermore, I have more information in the file, like for example coordinates, using the JSON Attribute as source setting, it didn't write that information back to mongo.

 

 

Hi @kathrinkarer,

 

Just checking: since you're also reading from MongoDB, you did properly set the Reader settings as well? Set Read Original JSON Document to Yes. Your whole JSON document will then be stored in the mongodb_json attribute. What happens if you write that back (using the Document Source attribute set to mongodb_json)? It should look exactly the same as before, I hope...

 


Hi @kathrinkarer,

 

Just checking: since you're also reading from MongoDB, you did properly set the Reader settings as well? Set Read Original JSON Document to Yes. Your whole JSON document will then be stored in the mongodb_json attribute. What happens if you write that back (using the Document Source attribute set to mongodb_json)? It should look exactly the same as before, I hope...

 

Hey @sander,

 

now it worked, thank you very much 🙂
Hey @sander,

 

now it worked, thank you very much :)
Good to hear that! And thanks for marking my answer :)

 


Reply