8000 GitHub - pgundlach/json2xml: JSON to XML converter
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pgundlach/json2xml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON to XML

A simple JSON to XML converter written in Go.

Usage:

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:

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

The (formatted) result is:

<data>
    <map>
        <array key="whatever">
            <entry>foo</entry>
            <entry>3.45</entry>
            <entry>bar</entry>
            <entry>1</entry>
        </array>
        <map key="something">
            <entry key="another">object</entry>
            <array key="and an">
                <entry>array</entry>
            </array>
        </map>
    </map>
</data>

About

JSON to XML converter

Topics

Resources

License

Stars

Watchers

Forks

Languages

0