GenerateJson Wyam.Json

Converts objects stored in metadata or elsewhere to JSON.
Generates JSON for a specified object (which can come from document metadata or elsewhere) and stores it as new content for each input document or in each document's metadata.

Package

This module exists in the Wyam.Json package which is not part of the core distribution. Add the following preprocessor directive to your configuration file to use it:
#n Wyam.Json
Alternativly, you can add all modules at once with the following preprocessor directive:
#n Wyam.All

Usage

  • GenerateJson(ContextConfig data, string destinationKey = null)

    The object returned by the specified delegate is converted to JSON, which then either replaces the content of each input document or is stored in the specified metadata key.

    • data

      A delegate that returns the object to convert to JSON.

    • destinationKey

      The metadata key where the JSON should be stored (or null to replace the content of each input document).

  • GenerateJson(DocumentConfig data, string destinationKey = null)

    The object returned by the specified delegate is converted to JSON, which then either replaces the content of each input document or is stored in the specified metadata key.

    • data

      A delegate that returns the object to convert to JSON.

    • destinationKey

      The metadata key where the JSON should be stored (or null to replace the content of each input document).

  • GenerateJson(string sourceKey, string destinationKey = null)

    The object stored in metadata at the specified key is converted to JSON, which then either replaces the content of each input document or is stored in the specified metadata key.

    • sourceKey

      The metadata key of the object to convert to JSON.

    • destinationKey

      The metadata key where the JSON should be stored (or null to replace the content of each input document).

Fluent Methods

Chain these methods together after the constructor to modify behavior.

  • WithIndenting(bool indenting = true)

    Specifies whether the generated JSON should be indented.

    • indenting

      If set to true, the JSON is indented.

GitHub