Skip to content
/ j2x Public

Encode arbitrary JSON strings and map[string]interface{} values as XML - the inverse of x2j.

License

Notifications You must be signed in to change notification settings

clbanning/j2x

Repository files navigation

j2x.go - Encode arbitrary JSON strings or map[string]interface{} values as XML.

NOTICE:

AS OF 3-FEB-2014 THE j2x PACKAGE IS NO LONGER SUPPORTED.

IT HAS BEEN DEPRECATED IN FAVOR OF mxj/j2x: https://github.com/clbanning/mxj/tree/master/j2x.

ANNOUNCEMENTS

01/23/14

NOTICE: FUNCTIONS HAVE BEEN RENAMED AND ARG/RETURN TYPES CHANGED. NOT BACKWARDS COMPATIBLE!

Added io.Writer and io.ReadWriter functions.  With the JsonReaderToXmlWriter() function
you can open a file/stream of JSON messages and write them out to a file/stream as XML.

01/22/14

Enable Go XML package encoding of empty elements - <tag ...></tag> instead of <tag .../>.

01/16/14

Included our io.Reader wrapper for bulk processing JSON strings to map[string]interface{}
or XML string values. See: JsonReaderToMap() and JsonReaderToDoc().

12/18/13

xml_marshal folder contains modified pkg/encoding/xml/marshal.go file that allows 
xml.Marshal() and xml.MarshalIndent() to use the j2x empty element encoding convention.

MOTIVATION

As part of our message hub project we want to make XML documents first class members
and had written the x2j package (http://godoc.org/github.com/clbanning/x2j) to parse
and filter XML encoded messages.  This package allows filtered messages to be delivered
as XML docs even if they are published to the hub as JSON encoded messages.

USAGE

The package is fairly well self-documented. (http://godoc.org/github.com/clbanning/j2x)  

XML ENCODING CONVENTIONS

   - JSON and map[string]interface{} keys that are prefixed with a hyphen, '-',
     are treated as attributes.
   - The value for the key '#text' is treated as the value for a simple element.
   - map[string]interface{} member values that are not standard JSON types - numbers,
	  character strings, boolean values, lists and JSON strings - are marshal'd using
	  xml.Marshal.  Thus, values can be complex structures, etc.

About

Encode arbitrary JSON strings and map[string]interface{} values as XML - the inverse of x2j.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages