java.lang.Object
com.blackhillsoftware.json.util.CompositeEntry
A class to combine several objects into one logical JSON object. For example,
you may want to write JSON containing information from both the SMF 30 Completion Section
and SMF 30 Identification Section.
To use, create a new CompositeEntry and add the required objects.
If the object is a complex object with it's own key-value
pairs e.g. most SMF sections, use add(Object)
to add the
JSON key-value pairs from the object to the CompositeEntry.
If the object is a simple object e.g. a string, number, time value etc.,
or you want the complex object to be nested in the CompositeEntry,
use add(String, Object)
to specify the
the JSON element key name.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An element in a CompositeEntry (used when generating JSON) -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdd an object to the composite entry.Add an object to the composite entry with a specific keyGet the Elements in this CompositeEntry (used when generating JSON)Get an object from the entry by name (only for entries added with a name)toString()
-
Constructor Details
-
CompositeEntry
public CompositeEntry()Create a new CompositeEntry
-
-
Method Details
-
add
Add an object to the composite entry with a specific key- Parameters:
key
- The JSON key to be used for the object (unique in this entry and not null).entry
- The object to be added to the combined JSON output.- Returns:
- this CompositeEntry to allow add methods to be chained.
-
add
Add an object to the composite entry. Simple entries like strings and numbers will receive a generated name - in that case you probably want to useadd(String, Object)
to specify the name.- Parameters:
entry
- The object to be added to the combined JSON output.- Returns:
- this CompositeEntry to allow add methods to be chained.
-
getEntry
Get an object from the entry by name (only for entries added with a name)- Parameters:
name
- the name of the entry- Returns:
- the object or null
-
getElements
Get the Elements in this CompositeEntry (used when generating JSON)- Returns:
- a list of Elements
-
toString
-