Class Dom4jDocumentJsonSerializer

java.lang.Object
com.fasterxml.jackson.databind.JsonSerializer<org.dom4j.Document>
org.craftercms.core.util.json.jackson.Dom4jDocumentJsonSerializer
All Implemented Interfaces:
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable

public class Dom4jDocumentJsonSerializer extends com.fasterxml.jackson.databind.JsonSerializer<org.dom4j.Document>
Custom Jackson serializer for Document. The following are the conversion patterns used between XML and JSON:
XML to JSON conversion patterns
XML JSON Access
<e/> "e": null o.e
<e>text</e> "e": "text" o.e
<e name="value" /> "e": { "name": "value" } o.e["name"]
<e name="value">text</e> "e": { "name": "value", "text": "text" } o.e["name"] o.e["text"]
<e><a>text</a><b>text</b></e> "e": { "a": "text", "b": "text" } o.e.a o.e.b
<e><a>text</a><a>text</a></e> "e": { "a": ["text", "text"] } o.e.a[0] o.e.a[1]
<e>text<a>text</a></e> "e": { "text": "text", "a": "text" } o.e["text"] o.e.a
<e>text<a>text</a>text</e> "e": { "text": ["text", "text"], "a": "text" }    o.e["text"][0] o.e["text"][1] o.e.a

IMPORTANT: XML Namespaces are ALWAYS ignored.
Author:
avasquez
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonSerializer

    com.fasterxml.jackson.databind.JsonSerializer.None
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String[]
     
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Class<org.dom4j.Document>
     
    void
    serialize(org.dom4j.Document doc, com.fasterxml.jackson.core.JsonGenerator jsonGenerator, com.fasterxml.jackson.databind.SerializerProvider provider)
     

    Methods inherited from class com.fasterxml.jackson.databind.JsonSerializer

    acceptJsonFormatVisitor, getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, serializeWithType, unwrappingSerializer, usesObjectId, withFilterId

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Dom4jDocumentJsonSerializer

      public Dom4jDocumentJsonSerializer()
  • Method Details

    • serialize

      public void serialize(org.dom4j.Document doc, com.fasterxml.jackson.core.JsonGenerator jsonGenerator, com.fasterxml.jackson.databind.SerializerProvider provider) throws IOException
      Specified by:
      serialize in class com.fasterxml.jackson.databind.JsonSerializer<org.dom4j.Document>
      Throws:
      IOException
    • handledType

      public Class<org.dom4j.Document> handledType()
      Overrides:
      handledType in class com.fasterxml.jackson.databind.JsonSerializer<org.dom4j.Document>