Logo Search packages:      
Sourcecode: libjson-java version File versions

net::sf::json::xml::XMLSerializer Class Reference

List of all members.

Detailed Description

Utility class for transforming JSON to XML an back.
When transforming JSONObject and JSONArray instances to XML, this class will add hints for converting back to JSON.

 JSONObject json = JSONObject.fromObject("{\"name\":\"json\",\"bool\":true,\"int\":1}");
 String xml = new XMLSerializer().write( json );
 <xmp><o class="object">
 <name type="string">json</name>
 <bool type="boolean">true</bool>
 <int type="number">1</int>
 JSONArray json = JSONArray.fromObject("[1,2,3]");
 String xml = new XMLSerializer().write( json );
 <e type="number">1</e>
 <e type="number">2</e>
 <e type="number">3</e>

Andres Almiray <aalmiray@users.sourceforge.net>

Definition at line 81 of file XMLSerializer.java.

Public Member Functions

void addNamespace (String prefix, String uri, String elementName)
void addNamespace (String prefix, String uri)
void clearNamespaces (String elementName)
void clearNamespaces ()
String getArrayName ()
String getElementName ()
String[] getExpandableProperties ()
String getObjectName ()
String getRootName ()
boolean isForceTopLevelObject ()
boolean isNamespaceLenient ()
boolean isRemoveNamespacePrefixFromElements ()
boolean isSkipNamespaces ()
boolean isSkipWhitespace ()
boolean isTrimSpaces ()
boolean isTypeHintsCompatibility ()
boolean isTypeHintsEnabled ()
JSON read (String xml)
JSON readFromFile (String path)
JSON readFromFile (File file)
JSON readFromStream (InputStream stream)
void removeNamespace (String prefix, String elementName)
void removeNamespace (String prefix)
void setArrayName (String arrayName)
void setElementName (String elementName)
void setExpandableProperties (String[] expandableProperties)
void setForceTopLevelObject (boolean forceTopLevelObject)
void setNamespace (String prefix, String uri, String elementName)
void setNamespace (String prefix, String uri)
void setNamespaceLenient (boolean namespaceLenient)
void setObjectName (String objectName)
void setRemoveNamespacePrefixFromElements (boolean removeNamespacePrefixFromElements)
void setRootName (String rootName)
void setSkipNamespaces (boolean skipNamespaces)
void setSkipWhitespace (boolean skipWhitespace)
void setTrimSpaces (boolean trimSpaces)
void setTypeHintsCompatibility (boolean typeHintsCompatibility)
void setTypeHintsEnabled (boolean typeHintsEnabled)
String write (JSON json, String encoding)
String write (JSON json)
 XMLSerializer ()

Private Member Functions

String addJsonPrefix (String str)
void addNameSpaceToElement (Element element)
boolean checkChildElements (Element element, boolean isTopLevel)
String getClass (Element element)
String getType (Element element, String defaultType)
String getType (Element element)
boolean hasNamespaces (Element element)
boolean isArray (Element element, boolean isTopLevel)
boolean isFunction (Element element)
boolean isNullObject (Element element)
boolean isObject (Element element, boolean isTopLevel)
Element newElement (String name)
JSON processArrayElement (Element element, String defaultType)
Object processElement (Element element, String type)
Element processJSONArray (JSONArray array, Element root, String[] expandableProperties)
Element processJSONObject (JSONObject jsonObject, Element root, String[] expandableProperties, boolean isRoot)
Element processJSONValue (Object value, Element root, Element target, String[] expandableProperties)
JSON processObjectElement (Element element, String defaultType)
String removeNamespacePrefix (String name)
void setOrAccumulate (JSONObject jsonObject, String key, Object value)
void setValue (JSONObject jsonObject, Element element, String defaultType)
void setValue (JSONArray jsonArray, Element element, String defaultType)
Object simplifyValue (JSONObject parent, Object json)
String trimSpaceFromValue (String value)
String writeDocument (Document doc, String encoding)

Private Attributes

String arrayName
String elementName
String[] expandableProperties
boolean forceTopLevelObject
boolean namespaceLenient
Map namespacesPerElement = new TreeMap()
String objectName
boolean removeNamespacePrefixFromElements
String rootName
Map rootNamespace = new TreeMap()
boolean skipNamespaces
boolean skipWhitespace
boolean trimSpaces
boolean typeHintsCompatibility
boolean typeHintsEnabled

Static Private Attributes

static final String[] EMPTY_ARRAY = new String[0]
static final String JSON_PREFIX = "json_"
static final Log log = LogFactory.getLog( XMLSerializer.class )


class  CustomElement
class  XomSerializer

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index