java.lang.Object
com.arc_e_tect.gradle.apionly.transcriberj.model.CanonicalJson

public final class CanonicalJson extends Object
RFC 8785, the JSON Canonicalization Scheme, over the maps, lists and scalars a YAML or JSON parser produces.

This is what makes a component's hash a property of its content rather than of how a bundler happened to format it.

  • Method Details

    • sha256

      public static String sha256(Object value)
      The lower-case hex SHA-256 of a value's canonical form, encoded as UTF-8.
      Parameters:
      value - a map, list, string, number, boolean or null
      Returns:
      the hash
    • write

      public static String write(Object value)
      A value's canonical form.
      Parameters:
      value - a map with string keys, list, string, number, boolean or null
      Returns:
      the canonical JSON text
      Throws:
      IllegalArgumentException - for anything JSON cannot hold