Skip to content

Unexpected values in add-on configuration JSON payload #59

Description

@gpeterso

Hello,

I've encountered some unexpected JSON serialization behavior with add-on configuration data. This is best illustrated with an example.

Example

When a Primo admin uploads the following configuration JSON:

{
 "disableWhenAvailableOnline": true,
 "disableForJournals": false,
 "ignoreCopyright": false,
 "matchOn": {
   "oclc": true,
   "isbn": false,
   "issn": false,
   "lccn": false
 }
}

... the actual JSON that get passed to the add-on when the remote module is bootstrapped looks like this 1:

{
  "disableWhenAvailableOnline" : "true",
  "disableForJournals" : "false",
  "ignoreCopyright" : "false",
  "matchOn" : "{oclc=true, isbn=false, issn=false, lccn=false}"
}

Issues

  1. Boolean values are serialized as strings, which can be subtly pernicious in javascript if you're expecting boolean values.
  2. Nested objects are serialized as "{key=value}" strings, which looks like the result of calling .toString() on a Map instance in Java.

Proposed next steps

I've already updated my add-on to handle these values, bit I think it would be helpful to address the following:

  1. Is this expected behavior?
  2. If so, could we add some documentation for add-on developers indicating any potentially surprising JSON serialization behavior?

Thank you!

Footnotes

  1. Note: this also corresponds with the add-on config data returned from the /primaws/rest/pub/configuration/vid/... endpoint ↩

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions