Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Streamlining user types in Qlik Cloud capacity-based subscriptions: Read the Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] tMongoDBOutput inserts only String fields

Hello,
When I try to load data in a MongoDB database, all fields are loaded as String, even if, in the schema, the fields are Integer, BigDecimal, Boolean, Date...
Is there a way to insert data in MongoDB with correct types with tMongoDBOutput component ?

My job :
tFileInputXML --> tMap --> tMongoDBOutput
The fields are Integer (or Date or Boolean...) in all the components.
tMongoDBOutput component is used with " Generate JSON Document" option.

Thanks in advance.
Labels (4)
4 Replies
Anonymous
Not applicable
Author

Hi 
MongoDB supports the following types: array, string, integer, float etc.. see 
http://json-lib.sourceforge.net/apidocs/jdk15/constant-values.html#net.sf.json.xml.JSONTypes.ARRAY
On tMongoDBOutput component, you need to add an attribute called 'type' to the element, and then right click on the attribute, select 'set a fixed value' to set the type name such as "float" which you want to declare the type of this element.

Shong
Anonymous
Not applicable
Author

Hi Shong,
Thanks for your answer.
Yes, I have succeeded to create Integer or Boolean fields with this method.
But no solution to create Date fields with the " Generate JSON Document" option.
I've contacted the Support to help me on this case, but no solution found with them.
Regards,
Tangi
Anonymous
Not applicable
Author

Hi 
Date is not a supported type by json, uses the default String type for it or generates each part of the year. For example:
{"year":2015,"month":03,"day":27}
BR
Shong
Anonymous
Not applicable
Author

Hi Shong,
Is there a way we can do this without using the " Generate JSON Document" option and still having the loop elements structure maintained in the tMongoDBOutput component.

I am able to create a Date field in MongoDB WITHOUT using the " Generate JSON Document" but I dont know how to group by a certain field and have repeating child elements in the tMongoDBOutput component.
Thanks,
-Bharat