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
- Boolean values are serialized as strings, which can be subtly pernicious in javascript if you're expecting boolean values.
- 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:
- Is this expected behavior?
- If so, could we add some documentation for add-on developers indicating any potentially surprising JSON serialization behavior?
Thank you!
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
.toString()on aMapinstance 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:
Thank you!
Footnotes
Note: this also corresponds with the add-on config data returned from the
/primaws/rest/pub/configuration/vid/...endpoint ↩