私は、Mule 3.6のワークフローでdatamapperに従うオブジェクトトランスフォーマーにJSONを渡して、JSONからオブジェクトへのトランスフォーマーが末尾のゼロを10進フィールドで削除して11.00になります。JSONからオブジェクトトランスフォーマへの丸め問題
JSON to Objectトランスフォーマがゼロの場合は最後の小数点以下の桁を削除し、2桁の小数点以下を置かないようにするにはどうすればよいですか?これは要件なので11.00を返しますか?
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<data-mapper:config name="CSV_To_JSON" transformationGraphPath="csv_to_json.grf" doc:name="CSV_To_JSON"/>
<flow name="deimal-point-flowFlow">
<file:inbound-endpoint path="${file.unprocessed.location}" moveToPattern="#[message.inboundProperties['originalFilename']]" moveToDirectory="${file.unprocessed.location}" responseTimeout="10000" doc:name="File">
<file:filename-regex-filter pattern="test.csv" caseSensitive="true"/>
</file:inbound-endpoint>
<data-mapper:transform config-ref="CSV_To_JSON" doc:name="CSV To JSON"/>
<json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
<json:object-to-json-transformer returnClass="java.lang.String" mimeType="application/json" doc:name="Object to JSON"/>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>
のtest.CSVファイルは次のようになります:
DeptID,Dept,Staff
5LL/A,Human Resources,4.00
私はjacksonオブジェクトマッパーを使用して2桁の小数点以下を保持できますが、値を文字列に変更することができました。 jacksonオブジェクトマッパーを使用する方法がありますが、小数値としてフィールド値を保持しますか? – user3165854