Class JSUtils.JSONSerializer
java.lang.Object
com.webmethods.caf.faces.render.util.JSUtils.JSONSerializer
- Enclosing class:
- JSUtils
Extensible class for serializing objects to json.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJSONSerializer
(Map<String, ?> mappedProperties) JSONSerializer
(Map<String, ?> mappedProperties, Collection<String> skippedProperties) -
Method Summary
Modifier and TypeMethodDescriptionMap of original property-names to re-mapped property-names.int
Max depth to recurse into objects.Set of original property-names to skip (in addition to any null re-mapped names).void
serialize
(Object o, Appendable b) Serializes specified object to specified appendable buffer.void
serialize
(Object o, Appendable b, List<Object> stack) Serializes specified object to specified appendable buffer.boolean
serializeContent
(Object o, Appendable b, List<Object> stack) Serializes the content of the specified map, list, or array (sans brackets) to the appendable buffer.void
serializeSecure
(Object o, Appendable b) Serializes object within prototype-compatible "secure" comment (ie "/*-secure-{}*/") to the appendable buffer.void
setMappedProperties
(Map<String, ?> mappedProperties) Map of original property-names to re-mapped property-names.void
setMaxDepth
(int maxDepth) Max depth to recurse into objects.void
setSkippedProperties
(Collection<String> skippedProperties) Set of original property-names to skip (in addition to any null re-mapped names).protected void
Writes the specified property name and colon to the appendable buffer (ie "foo:" or "'foo bar':").
-
Field Details
-
m_maxDepth
protected int m_maxDepth -
m_mappedProperties
-
m_skippedProperties
-
-
Constructor Details
-
JSONSerializer
public JSONSerializer() -
JSONSerializer
-
JSONSerializer
-
-
Method Details
-
serialize
Serializes specified object to specified appendable buffer.- Parameters:
o
- Object to serialize.b
- Buffer.- Throws:
IOException
-
serialize
Serializes specified object to specified appendable buffer. Subclasses should override the method with this signature (rather than the method without the stack param).- Parameters:
o
- Object to serialize.b
- Buffer.stack
- Stack of objects already serialized (if null, lazily init'd).- Throws:
IOException
-
serializeSecure
Serializes object within prototype-compatible "secure" comment (ie "/*-secure-{}*/") to the appendable buffer.- Parameters:
o
- Object to serialize.b
- Buffer.- Throws:
IOException
-
serializeContent
Serializes the content of the specified map, list, or array (sans brackets) to the appendable buffer.- Parameters:
map
- Object to serialize.b
- Buffer.stack
- Stack of objects already serialized (if null, lazily init'd).- Throws:
IOException
-
writePropertyName
Writes the specified property name and colon to the appendable buffer (ie "foo:" or "'foo bar':").- Parameters:
o
- Property name.b
- Buffer.- Throws:
IOException
-
getMappedProperties
Map of original property-names to re-mapped property-names. Properties whose names have been re-mapped to null will be skipped. -
setMappedProperties
Map of original property-names to re-mapped property-names. Properties whose names have been re-mapped to null will be skipped. -
getSkippedProperties
Set of original property-names to skip (in addition to any null re-mapped names). -
setSkippedProperties
Set of original property-names to skip (in addition to any null re-mapped names). -
getMaxDepth
public int getMaxDepth()Max depth to recurse into objects. A depth of zero (0) means properties even of the top-level object aren't serialized. -
setMaxDepth
public void setMaxDepth(int maxDepth) Max depth to recurse into objects. A depth of zero (0) means properties even of the top-level object aren't serialized.
-