Package generic.json
Class Json
java.lang.Object
org.apache.commons.lang3.builder.ToStringStyle
generic.json.Json
- All Implemented Interfaces:
Serializable
public class Json
extends org.apache.commons.lang3.builder.ToStringStyle
A utility class to format strings in JSON format. This is useful for easily generating
toString() representations of objects.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAToStringStyleinspired byToStringStyle.JSON_STYLEthat places object fields on newlines for more readability -
Field Summary
FieldsFields inherited from class org.apache.commons.lang3.builder.ToStringStyle
DEFAULT_STYLE, JSON_STYLE, MULTI_LINE_STYLE, NO_CLASS_NAME_STYLE, NO_FIELD_NAMES_STYLE, SHORT_PREFIX_STYLE, SIMPLE_STYLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringCreates a Json string representation of the given object and all of its fields.static StringCreates a Json string representation of the given object and the given fieldsstatic StringtoStringExclude(Object o, String... excludedFields) Creates a Json string representation of the given object and all of its fields except for those in the given exclusion listMethods inherited from class org.apache.commons.lang3.builder.ToStringStyle
append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, append, appendClassName, appendContentEnd, appendContentStart, appendCyclicObject, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendEnd, appendFieldEnd, appendFieldSeparator, appendFieldStart, appendIdentityHashCode, appendInternal, appendNullText, appendStart, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummarySize, appendSuper, appendToString, getArrayEnd, getArraySeparator, getArrayStart, getContentEnd, getContentStart, getFieldNameValueSeparator, getFieldSeparator, getNullText, getShortClassName, getSizeEndText, getSizeStartText, getSummaryObjectEndText, getSummaryObjectStartText, isArrayContentDetail, isDefaultFullDetail, isFieldSeparatorAtEnd, isFieldSeparatorAtStart, isFullDetail, isUseClassName, isUseFieldNames, isUseIdentityHashCode, isUseShortClassName, reflectionAppendArrayDetail, removeLastFieldSeparator, setArrayContentDetail, setArrayEnd, setArraySeparator, setArrayStart, setContentEnd, setContentStart, setDefaultFullDetail, setFieldNameValueSeparator, setFieldSeparator, setFieldSeparatorAtEnd, setFieldSeparatorAtStart, setNullText, setSizeEndText, setSizeStartText, setSummaryObjectEndText, setSummaryObjectStartText, setUseClassName, setUseFieldNames, setUseIdentityHashCode, setUseShortClassName
-
Field Details
-
WITH_NEWLINES
-
-
Constructor Details
-
Json
public Json()
-
-
Method Details
-
toString
Creates a Json string representation of the given object and all of its fields. To exclude some fields, calltoStringExclude(Object, String...). To only include particular fields, callToStringStyle.appendToString(StringBuffer, String).- Parameters:
o- the object- Returns:
- the string
-
toString
Creates a Json string representation of the given object and the given fields- Parameters:
o- the objectincludFields- the fields to include- Returns:
- the string
-
toStringExclude
Creates a Json string representation of the given object and all of its fields except for those in the given exclusion list- Parameters:
o- the objectexcludedFields- the excluded field names- Returns:
- the string
-