Class JsonLDSerializer

java.lang.Object
org.spdx.v3jsonldstore.JsonLDSerializer

public class JsonLDSerializer extends Object
Serializer to serialize a model store containing SPDX Spec version 3 elements

The serialize() method will serialize the @graph for all SPDX elements stored in the model store.

The serialize(SpdxElement element) will serialize a single element.
Author:
Gary O'Neall
  • Constructor Details

    • JsonLDSerializer

      public JsonLDSerializer(com.fasterxml.jackson.databind.ObjectMapper jsonMapper, boolean pretty, boolean useExternalListedElements, String specVersion, IModelStore modelStore) throws net.jimblackler.jsonschemafriend.GenerationException
      Serializer to serialize a model store containing SPDX 3 elements
      Parameters:
      jsonMapper - mapper to use for serialization
      pretty - true if the format is to be more verbose
      useExternalListedElements - if true, don't serialize any listed licenses or exceptions - treat them as external
      specVersion - SemVer representation of the SPDX spec version
      modelStore - store where the SPDX elements are stored
      Throws:
      net.jimblackler.jsonschemafriend.GenerationException - if the JSON schema is not found or is not valid
  • Method Details

    • serialize

      public com.fasterxml.jackson.databind.JsonNode serialize(@Nullable CoreModelObject objectToSerialize) throws InvalidSPDXAnalysisException
      Parameters:
      objectToSerialize - optional SPDX Document or single element to serialize
      Returns:
      the root node of the JSON serialization
      Throws:
      InvalidSPDXAnalysisException - on errors retrieving the information for serialization
    • getSchema

      public JsonLDSchema getSchema()
      Returns the JSON-LD schema used for serialization
      Returns:
      JSON-LD Schema