我正在做一個Web服務調用和檢索一個JSON有效載荷,例如:JSON有效載荷攝取到MySQL數據庫使用騾子ESB
[
{
"type": " --T::00"
},
{
"address": "10049 College Way N",
"longitude": "-122.335022",
"latitude": "47.701756",
"incident_number": "F110104009",
"type": "Aid Response",
"report_location": {
"needs_recoding": false,
"longitude": "-122.335022",
"latitude": "47.701756"
}
},
{
"address": "5929 Beach Dr Sw",
"longitude": "-122.397816",
"latitude": "47.550431",
"incident_number": "F110104008",
"type": "Aid Response",
"report_location": {
"needs_recoding": false,
"longitude": "-122.397816",
"latitude": "47.550431"
}
}
我遍歷,各條線和攝入鍵值到一個MySQL數據庫表。我期望第一個值'type -t00'被插入,其中incident_number,經度,緯度爲空白。然而,在隨後的每一次迭代中,我都希望攝取能夠起作用。相反,我得到如下:
ID Longitude Latitude incident_number type
1 null null null --T::00
65 null null null 1RED 1 Unit
70 null null null 1RED 1 Unit
313 null null null 1RED 1 Unit
314 null null null 1RED 1 Unit
315 null null null 1RED 1 Unit
316 null null null 1RED 1 Unit
正在發生的事情是,只有類型被正確地攝取從JSON有效載荷但其它有效載荷值爲null。在我調試的時候,我確實看到了迭代,並且可以清楚地識別payload.incident_number,payload.longitude,但在我看來,問題已被攝入。我已經嘗試只攝入了incident_number,但在表中爲空。
任何幫助,非常感謝。
我下面configuration.xml中:
<db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="demo"
password="Welcome1" database="demo" doc:name="MySQL Configuration"/>
<flow name="seattleemergencyFlow1" doc:name="seattleemergencyFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8900"
path="get-emergency" doc:name="HTTP"></http:inbound-endpoint>
<http:outbound-endpoint exchange-pattern="request-response" host="data.seattle.gov"
port="80" path="resource/kzjm-xkqj.json?" method="GET" contentType="application/json"
doc:name="HTTP"></http:outbound-endpoint>
<json:json-to-object-transformer returnClass="java.util.List" doc:name="JSON to Object">
</json:json-to-object-transformer>
<foreach doc:name="For Each">
<db:insert config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[INSERT INTO emergencyrecords
(incident_number, type, longitude)
VALUES
(
#[payload.incident_number],
#[payload.type],
#[payload.longitude])]]></db:parameterized-query>
</db:insert>
</foreach>
</flow>
</mule>
對不起David..Just學習論壇。我已經完成了我之前的問題。謝謝你的幫助。 – sam 2014-10-06 16:29:11