An open API service indexing awesome lists of open source software.

https://github.com/covrom/xml2json

Universal unmarshal xml and re-marshal it to json
https://github.com/covrom/xml2json

conversion golang json xml

Last synced: 4 months ago
JSON representation

Universal unmarshal xml and re-marshal it to json

Awesome Lists containing this project

README

          

# xml2json
Unmarshal xml and marshal it to json universally.

## Example of translation

This xml
```xml


























WSDL File for HelloService



```
produces this json
```json
{
"definitions": {
"binding": {
"binding": {
"style": "rpc",
"transport": "http://schemas.xmlsoap.org/soap/http"
},
"name": "Hello_Binding",
"operation": {
"input": {
"body": {
"encodingStyle": "http://schemas.xmlsoap.org/soap/encoding/",
"namespace": "urn:examples:helloservice",
"use": "encoded"
}
},
"name": "sayHello",
"operation": {
"soapAction": "sayHello"
},
"output": {
"body": {
"encodingStyle": "http://schemas.xmlsoap.org/soap/encoding/",
"namespace": "urn:examples:helloservice",
"use": "encoded"
}
}
},
"type": "tns:Hello_PortType"
},
"message": [
{
"name": "SayHelloRequest",
"part": {
"name": "firstName",
"type": "xsd:string"
}
},
{
"name": "SayHelloResponse",
"part": {
"name": "greeting",
"type": "xsd:string"
}
}
],
"name": "HelloService",
"portType": {
"name": "Hello_PortType",
"operation": {
"input": {
"message": "tns:SayHelloRequest"
},
"name": "sayHello",
"output": {
"message": "tns:SayHelloResponse"
}
}
},
"service": {
"documentation": "WSDL File for HelloService",
"name": "Hello_Service",
"port": {
"address": {
"location": "http://www.examples.com/SayHello/"
},
"binding": "tns:Hello_Binding",
"name": "Hello_Port"
}
},
"soap": "http://schemas.xmlsoap.org/wsdl/soap/",
"targetNamespace": "http://www.examples.com/wsdl/HelloService.wsdl",
"tns": "http://www.examples.com/wsdl/HelloService.wsdl",
"xmlns": "http://schemas.xmlsoap.org/wsdl/",
"xsd": "http://www.w3.org/2001/XMLSchema"
}
}
```
Benchamrk for this sample:
```
BenchmarkXMLNode_UnmarshalXML-4 10000 135491 ns/op
BenchmarkXMLNode_MarshalJSON-4 20000 85595 ns/op
```