Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for JSON #3007

Merged
merged 7 commits into from
Dec 15, 2022
Merged

Support for JSON #3007

merged 7 commits into from
Dec 15, 2022

Commits on Dec 13, 2022

  1. chore: Vendor Go 1.17.13 encoding/json

    This patch vendors the sources from Go 1.17.13's encoding/json
    package in the package vim25/json.
    akutz committed Dec 13, 2022
    Configuration menu
    Copy the full SHA
    a581fd0 View commit details
    Browse the repository at this point in the history

Commits on Dec 15, 2022

  1. chore: JSON Encoding w Discriminator Support

    This patch introduces support for discriminators to the "encoding/json" package.
    A discriminator is a field in a JSON object that indicates the object's type.
    For example:
    
            {
                "breed": "Lab"
            }
    
    The above JSON does not indicate the Go type into which the object should be
    decoded. However, it is possible to store that Go type information along with
    the JSON:
    
            {
                "_typeName": "Dog",
                "breed": "Lab"
            }
    
    The "_typeName" field teaches the JSON decoder to unmarshal the object into the
    Go type named "Dog".
    
    This patch introduces functions for the json.Encoder and json.Decoder that may
    be used to active support for discriminators.
    akutz committed Dec 15, 2022
    Configuration menu
    Copy the full SHA
    5caa20a View commit details
    Browse the repository at this point in the history
  2. chore: Include LICENSE in vendored JSON pkg

    This patch adds Go's LICENSE file to the vendored JSON package.
    akutz committed Dec 15, 2022
    Configuration menu
    Copy the full SHA
    908aa06 View commit details
    Browse the repository at this point in the history
  3. docs: Add README to vendored JSON pkg

    This patch adds a README to the vendored JSON package describing
    its purpose and how to show the diff between the original sources
    and the patch applied to the vendored copy.
    akutz committed Dec 15, 2022
    Configuration menu
    Copy the full SHA
    e4a3688 View commit details
    Browse the repository at this point in the history
  4. chore: Exclude vim25/json from CodeStyle workflow

    This patch excludes the vendored vim25/json package from the
    GitHub action that checks code style for Go sources.
    akutz committed Dec 15, 2022
    Configuration menu
    Copy the full SHA
    e639aba View commit details
    Browse the repository at this point in the history
  5. api: Generate JSON tags

    This patch updates the type generation code to support adding
    JSON tags to generated type field data.
    
    BREAKING:
    
    Updating the `vim25/types` with camelCased, JSON tags affects
    the output of the `govc` command when using the `-json` flag
    to emit results as JSON. Field names that used to be PascalCased
    will now be camelCased. Queries for tools that parse JSON, such
    as `jq`, will need to be updated to use the new camelCased fields.
    akutz committed Dec 15, 2022
    Configuration menu
    Copy the full SHA
    9920086 View commit details
    Browse the repository at this point in the history
  6. api: JSON Discriminators for vim25/types

    This patch adds support to GoVmomi for marshaling/unmarshaling
    the vim25/types (and other VMODL1 types) to/from JSON using:
    
    * a customized version of the Golang encoding/json package that
      relies upon...
    * a new discriminator field added to every every complex object
      marshaled to JSON, the "_typeName" field. this field's value
      must match the value of the type's registered type name from
      the type registry
    akutz committed Dec 15, 2022
    Configuration menu
    Copy the full SHA
    4e6d642 View commit details
    Browse the repository at this point in the history