Package htsjdk.beta.io.bundle
Class BundleJSON
java.lang.Object
htsjdk.beta.io.bundle.BundleJSON
Methods for serializing and deserializing Bundles to and from JSON strings.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BundleCreate a Bundle from a jsonString.Create a Bundle from jsonString using a custom class that implementsIOPathfor all resources.toBundleList(String jsonString) Create a Listfrom a jsonString. toBundleList(String jsonString, Function<String, T> ioPathConstructor) Create a Listfrom a jsonString, using a custom class that implements IOPathfor all resources.static StringSerialize a bundle to a JSON string representation.static StringConvert a (non-empty) List of Bundles to a JSON array string representation.
-
Field Details
-
BUNDLE_EXTENSION
- See Also:
-
JSON_PROPERTY_SCHEMA
- See Also:
-
JSON_PROPERTY_SCHEMA_NAME
- See Also:
-
JSON_PROPERTY_SCHEMA_VERSION
- See Also:
-
JSON_PROPERTY_PRIMARY
- See Also:
-
JSON_PROPERTY_PATH
- See Also:
-
JSON_PROPERTY_FORMAT
- See Also:
-
JSON_SCHEMA_NAME
- See Also:
-
JSON_SCHEMA_VERSION
- See Also:
-
-
Constructor Details
-
BundleJSON
public BundleJSON()
-
-
Method Details
-
toJSON
Serialize a bundle to a JSON string representation. All resources in the bundle must beIOPathResources for serialization to succeed. Stream resources cannot be serialized.- Parameters:
bundle- theBundleto serialize to JSON- Returns:
- a JSON string representation of this bundle
- Throws:
IllegalArgumentException- if any resource in bundle is not an IOPathResources.
-
toJSON
Convert a (non-empty) List of Bundles to a JSON array string representation.- Parameters:
bundles- a List of Bundles to serialize to JSON- Returns:
- a JSON string (array) representation of the list of bundles
-
toBundle
Create a Bundle from a jsonString.- Parameters:
jsonString- a valid JSON string conforming to the bundle schema (for compatibility, a bundle list is also accepted, as long as it only contains a single bundle)- Returns:
- a
Bundlecreated from jsonString
-
toBundle
public static <T extends IOPath> Bundle toBundle(String jsonString, Function<String, T> ioPathConstructor) Create a Bundle from jsonString using a custom class that implementsIOPathfor all resources. (For compatibility, a bundle list string is also accepted, as long as it only contains a single bundle).- Type Parameters:
T- the IOPath-derived type to use for IOPathResources- Parameters:
jsonString- a valid JSON string conforming to the bundle schemaioPathConstructor- a function that takes a string and returns an IOPath-derived class of type- Returns:
- a newly created
Bundle
-
toBundleList
public static <T extends IOPath> List<Bundle> toBundleList(String jsonString, Function<String, T> ioPathConstructor) Create a Listfrom a jsonString, using a custom class that implements IOPathfor all resources.- Type Parameters:
T- IOPath-derived class to use for IOPathResources- Parameters:
jsonString- the json string must conform to the bundle schema, and may contain an array or single objectioPathConstructor- constructor to use to create the backing IOPath for all resources- Returns:
- List
-
toBundleList
Create a Listfrom a jsonString.
-