Разбор XML получил в объект JSON

голоса
44

У меня есть объект JSON, содержащий содержимое XML в виде строки.

<?xml version="1.0" encoding="UTF-8" standalone="no"?><serviceDescription><id>nitro:in-app:1fae04fd-79dd-4252-82fc-bcc6d04b8566:6a899379-5b96-4387-89ba-246d7c07ec48</id><defaultLocale>en</defaultLocale><transportId>HTTPServiceTransport</transportId><name xml:lang="en">http://localhost:9080/MFRestService/StreeboRuntime/myservice?x={"count":10}</name><description xml:lang="en"/><inbound><parameters><parameter><id>request-query-x</id><name xml:lang="en">x</name><description xml:lang="en"/><mandatory>true</mandatory><type>STRING</type></parameter></parameters><serviceMapping><constants><constant><id>service-description-body</id><value><![CDATA[{"name":"http://localhost:9080/MFRestService/StreeboRuntime/myservice?x={\\\\"count\\\\":10}","request-method":"GET","original-url":"http://localhost:9080/MFRestService/StreeboRuntime/myservice?x={\\\\"count\\\\":10}","sampleInputJSON":"","request-url":"http://localhost:9080/MFRestService/StreeboRuntime/myservice","sampleOutputJSON":"[{\\\\"Count\\\\":\\\\"9\\\\"},{\\\\"Count\\\\":\\\\"9\\\\"},{\\\\"Count\\\\":\\\\"9\\\\"},{\\\\"Count\\\\":\\\\"9\\\\"},{\\\\"Count\\\\":\\\\"9\\\\"},{\\\\"Count\\\\":\\\\"9\\\\"},{\\\\"Count\\\\":\\\\"9\\\\"},{\\\\"Count\\\\":\\\\"9\\\\"},{\\\\"Count\\\\":\\\\"9\\\\"},{\\\\"Count\\\\":\\\\"9\\\\"}]","fixed-request-parameters":[],"mappable-request-parameters":[{"id":"request-query-x","name":"x","required":true,"index":0}],"mappable-response-parameters":[]}]]></value></constant><constant><id>request-url</id><value><![CDATA[http://localhost:9080/MFRestService/StreeboRuntime/myservice]]></value></constant><constant><id>request-method</id><value><![CDATA[GET]]></value></constant><constant><id>original-url</id><value><![CDATA[http://localhost:9080/MFRestService/StreeboRuntime/myservice?x={"count":10}]]></value></constant></constants><mapping><mapping source="constant:request-url" sourceType="STRING" target="transport:request-url" targetType="STRING"/><mapping source="constant:original-url" sourceType="STRING" target="transport:original-url" targetType="STRING"/><mapping source="constant:service-description-body" sourceType="STRING" target="transport:service-description-body" targetType="STRING"/><mapping source="constant:request-method" sourceType="STRING" target="transport:request-method" targetType="STRING"/><mapping source="parameter:request-query-x" sourceType="STRING" target="transport:request-query-x" targetType="STRING"/></mapping></serviceMapping></inbound><outbound><parameters><parameter><id>items</id><name xml:lang="en">items</name><description xml:lang="en"/><mandatory>false</mandatory><type>LIST</type><parameters><parameter><id>Count</id><name xml:lang="en">Count</name><description xml:lang="en"/><mandatory>false</mandatory><type>STRING</type></parameter></parameters></parameter></parameters><serviceMapping><mapping><mapping source="transport:response-entity" sourceType="JSON" target="parameter:items" targetType="STRING"><mapping sourceRef="Count" sourceType="JSON" target="parameter:Count" targetType="STRING"/></mapping></mapping></serviceMapping></outbound></serviceDescription>

Она содержит многочисленные & Л.Т., & GT, & Quot и все такие и символы. Как мне удается заменить их с реальными символами с помощью Java.

Моя конечная цель состоит в том, чтобы преобразовать это содержимое XML в JSON.

Задан 20/02/2018 в 05:33
пользователем
На других языках...                            

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more