简体   繁体   English

在 WSO2 Integration Studio 中将 integer 字段从 mongo 转换为 Json 格式时出现转换错误

[英]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.

相关问题 如何从WSo2 Integration Studio数据服务项目中读取mongo查询结果为Json格式的数据? - How to read data from mongo query result as Json Format in WSo2 Integration Studio Data Service Project? 在 WSo2 Integration Studio 中使用聚合时出现错误“未知 MongoDB 操作‘聚合’”? - Error 'unknown MongoDB operation 'aggregate'' when using aggregate in WSo2 Integration Studio? 如何增加 WSO2 Integration Studio 的超时时间? - How to increase the timeout at WSO2 Integration Studio? 在 wso2 Integration Studio 中安排任务 - Scheduling tasks in wso2 Integration Studio wso2 Integration Studio中动态变量的全球化 - Globalization of dynamic variables in wso2 Integration Studio 在 WSO2 Integration Studio 中读取 a.txt 文件 - Reading a .txt file in WSO2 Integration Studio 在装有 macOS Monterey 12.6 的 Macbook Pro 中打开 WSO2 Integration Studio 8.1.0 时出错 - Error to open WSO2 Integration Studio 8.1.0 in a Macbook Pro with macOS Monterey 12.6 如何在创建 API 时发送查询参数,该 API 使用 WSO2 Integration Studio 中的查询参数? - How to send a query parameter when creating an API that consumes an API that takes a query parameter in WSO2 Integration Studio? 我在wso2集成工作室的rest api项目中遇到问题 - I got a problem in rest api project in wso2 integration studio JSON 到 XML 和 XML 到 JSON 在 WSO2 EI 中的转换 - JSON TO XML and XML to JSON conversion in WSO2 EI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM