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
- Host: GitHub
- URL: https://github.com/covrom/xml2json
- Owner: covrom
- License: mit
- Created: 2018-12-05T21:22:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-06T09:20:20.000Z (over 7 years ago)
- Last Synced: 2024-06-19T05:54:32.487Z (about 2 years ago)
- Topics: conversion, golang, json, xml
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
```