@metreeca/qest - v0.10.0
    Preparing search index...

    Function decodeResource

    • Decodes a resource state from a JSON string.

      Parses a JSON string into a Resource, recursively resolving internal IRIs against the provided base. The decoded resource is validated and deeply frozen unless lenient is true.

      Parameters

      • json: string

        The JSON-serialised Resource

      • options: DecoderOpts = {}

        Decoding options

        Configuration options for decoding operations.

        • Optional Readonlybase?: IRI

          Base IRI for IRI resolution (must be absolute and hierarchical).

          Resolves internal IRIs to absolute form.

          If omitted, IRIs are resolved against app.

        • Optional Readonlylenient?: boolean

          Disables structural validation after decoding.

          Allows the caller to handle validation independently using more advanced or specialised tools, for example for improved error reporting.

          • When true, structural checks are skipped and only syntax errors are reported through exceptions
          • When false, both syntax and structural errors are reported through exceptions

          If omitted, decoders apply internal structural validators to the input.

      Returns Resource

      The decoded deeply immutable resource with resolved IRIs

      TypeError If base is not a hierarchical IRI

      TypeError If the decoded value fails structural validation (unless lenient is true)

      SyntaxError If json is not valid JSON

      decodeResource(
      '{"id":"/products/42","name":"Widget","price":29.99}',
      { base: "https://example.com/" }
      );
      // → { id: "https://example.com/products/42", name: "Widget", price: 29.99 }