[英]Conversion error when converting an integer field from mongo to Json format as result in WSO2 Integration Studio
In WSO2 Integration Studio Data Service project, I am extracting data from mongo database using find query.在 WSO2 Integration Studio 数据服务项目中,我使用查找查询从 mongo 数据库中提取数据。 While showing an integer field in json format, I get the following error.
在以 json 格式显示 integer 字段时,出现以下错误。 I have a field called 'RoomCount' and an integer type that returns a Mongo query result.
我有一个名为“RoomCount”的字段和一个返回 Mongo 查询结果的 integer 类型。 I am getting error while converting this field to Json Format as below.
将此字段转换为 Json 格式时出现错误,如下所示。 When I am pulling string type data its work but integer,double.. doesnt work !
当我提取字符串类型数据时,它可以工作,但 integer,double.. 不起作用!
<query id="MunicipalBuildingDetails" useConfig="MongoDb">
<expression>collectionName.find()</expression>
<result outputType="json" escapeNonPrintableChar="true">{
Result:
{
Data:
[{
"Col1":"$document.RoomCount"
}
]
}
}</result>
</query>
Error is;错误是;
DS Fault Message: Error occurred when retrieving data. :JSONObject["RoomCount"] not a string.
How can I solve this?我该如何解决这个问题?
This is another issue with the Mongo JSON conversion implementation.这是 Mongo JSON 转换实现的另一个问题。 The values are always read as Strings.
这些值始终作为字符串读取。 If you have any Integers rather than reading the element return the complete response and let the client handle it or handle it in the integration layer.
如果您有任何整数而不是读取元素,则返回完整的响应并让客户端处理它或在集成层中处理它。
<query id="MunicipalBuildingDetails" useConfig="MongoDb">
<expression>collectionName.find()</expression>
<result outputType="json" escapeNonPrintableChar="true">{
Result:
{
Data:
[{
"Col1":"$document"
}
]
}
}</result>
</query>
Another alternative is to use the MongoDB connector.另一种选择是使用 MongoDB 连接器。 Also I'm not sure whether there is any option in MongoDB to always return values as Strings, may be worth checking that option as well.
此外,我不确定 MongoDB 中是否有任何选项始终将值作为字符串返回,也可能值得检查该选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.