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

https://github.com/pgundlach/json2xml

JSON to XML converter
https://github.com/pgundlach/json2xml

converter go golang json xml

Last synced: 3 months ago
JSON representation

JSON to XML converter

Awesome Lists containing this project

README

          

# JSON to XML

A simple JSON to XML converter written in Go.

Usage:

```go
package main

import (
"fmt"
"log"
"os"

"github.com/pgundlach/json2xml"
)

func dothings() error {
f, err := os.Open("myfile.json")
if err != nil {
return err
}
str, err := json2xml.ToXML(f)
if err != nil {
return err
}
fmt.Println(str)
return nil
}

func main() {
err := dothings()
if err != nil {
log.Fatal(err)
}
}
```

where `myfile.json` is:

```json
{
"whatever": [
"foo",
3.45,
"bar",
1
],
"something": {
"another": "object",
"and an": [
"array"
]
}
}
```

The (formatted) result is:

```xml



foo
3.45
bar
1


object

array


```