Parsing 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>

Περιέχει πολλά & lt, & 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