-
Notifications
You must be signed in to change notification settings - Fork 1
GSIP 156
Proposal to upgrade the JSON library used by the REST configuration module from jettison 1.0.1 to jettison 1.2.
Torben Barsballe
This proposal is for GeoServer 2.11-beta.
- Under Discussion
- In Progress
- Completed
- Rejected
- Deferred
To fix JSON encoding bugs caused by errors in the Jettison 1.0.1 library
The GeoServer REST configuration module delegates from XStream to the Jettison library to encode JSON responses. Jettison 1.0.1 has known issues, some of which are fixed in Jettison 1.2. This has resulted in some errors in the REST config JSON responses, such as GEOS-7771 and GEOS-7873.
Due to differences between Jettison 1.0.1 and 1.2, this upgrade will result in an API change to the GeoServer REST configuration JSON output format.
The change occurs when encoding lists of objects as JSON:
Example: geoserver/rest/workspaces.json
:
With Jettison 1.0.1
{
"workspaces": {
"workspace": [
{
"href": "http://localhost:8080/geoserver/rest/workspaces/cite.json",
"name": "cite"
},
{
"href": "http://localhost:8080/geoserver/rest/workspaces/tiger.json",
"name": "tiger"
},
{
"href": "http://localhost:8080/geoserver/rest/workspaces/nurc.json",
"name": "nurc"
},
{
"href": "http://localhost:8080/geoserver/rest/workspaces/sde.json",
"name": "sde"
},
{
"href": "http://localhost:8080/geoserver/rest/workspaces/it.geosolutions.json",
"name": "it.geosolutions"
},
{
"href": "http://localhost:8080/geoserver/rest/workspaces/topp.json",
"name": "topp"
},
{
"href": "http://localhost:8080/geoserver/rest/workspaces/sf.json",
"name": "sf"
}
]
}
}
With Jettison 1.2:
{
"workspaces": [
{
"workspace": [
{
"href": "http://localhost:8080/geoserver/rest/workspaces/sf.json",
"name": "sf"
},
{
"href": "http://localhost:8080/geoserver/rest/workspaces/sde.json",
"name": "sde"
},
{
"href": "http://localhost:8080/geoserver/rest/workspaces/cite.json",
"name": "cite"
},
{
"href": "http://localhost:8080/geoserver/rest/workspaces/nurc.json",
"name": "nurc"
},
{
"href": "http://localhost:8080/geoserver/rest/workspaces/tiger.json",
"name": "tiger"
},
{
"href": "http://localhost:8080/geoserver/rest/workspaces/it.geosolutions.json",
"name": "it.geosolutions"
},
{
"href": "http://localhost:8080/geoserver/rest/workspaces/topp.json",
"name": "topp"
}
]
}
]
}
Notice how the workspaces
list object has been wrapped in a single element array: from {workspaces: { workspace: [...] } }
to {workspaces: [ { workspace: [...] } ] }
.
This can be better observed in the Resources REST api:
Elsewhere, single element lists are now converted to objects:
Example: REST resources geoserver/rest/resource/security/auth?format=json
Jettison 1.0.1, single-element array:
{
"ResourceDirectory": {
"children": {
"child": [
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/security/auth/default",
"rel": "alternate",
"type": "application/json"
},
"name": "default"
}
]
},
"lastModified": "2017-01-31 17:52:14.0 UTC",
"name": "auth",
"parent": {
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/security",
"rel": "alternate",
"type": "application/json"
},
"path": "/security"
}
}
}
Jettison 1.2, single-element array:
{
"ResourceDirectory": {
"children": [
{
"child": {
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/security/auth/default",
"rel": "alternate",
"type": "application/json"
},
"name": "default"
}
}
],
"lastModified": "2016-11-23 20:45:44.0 UTC",
"name": "auth",
"parent": {
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/security",
"rel": "alternate",
"type": "application/json"
},
"path": "/security"
}
}
}
Jettison 1.0.1. multi-element array:
{
"ResourceDirectory": {
"children": {
"child": [
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/cite",
"rel": "alternate",
"type": "application/json"
},
"name": "cite"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/default.xml",
"rel": "alternate",
"type": "application/xml"
},
"name": "default.xml"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/it.geosolutions",
"rel": "alternate",
"type": "application/json"
},
"name": "it.geosolutions"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/nurc",
"rel": "alternate",
"type": "application/json"
},
"name": "nurc"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/sde",
"rel": "alternate",
"type": "application/json"
},
"name": "sde"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/sf",
"rel": "alternate",
"type": "application/json"
},
"name": "sf"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/tiger",
"rel": "alternate",
"type": "application/json"
},
"name": "tiger"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/topp",
"rel": "alternate",
"type": "application/json"
},
"name": "topp"
}
]
},
"lastModified": "2017-01-18 19:02:38.0 UTC",
"name": "workspaces",
"parent": {
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/",
"rel": "alternate",
"type": "application/json"
},
"path": "/"
}
}
}
Jettison 1.2:
{
"ResourceDirectory": {
"children": [
{
"child": [
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/cite",
"rel": "alternate",
"type": "application/json"
},
"name": "cite"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/default.xml",
"rel": "alternate",
"type": "application/xml"
},
"name": "default.xml"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/it.geosolutions",
"rel": "alternate",
"type": "application/json"
},
"name": "it.geosolutions"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/nurc",
"rel": "alternate",
"type": "application/json"
},
"name": "nurc"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/sde",
"rel": "alternate",
"type": "application/json"
},
"name": "sde"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/sf",
"rel": "alternate",
"type": "application/json"
},
"name": "sf"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/tiger",
"rel": "alternate",
"type": "application/json"
},
"name": "tiger"
},
{
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/workspaces/topp",
"rel": "alternate",
"type": "application/json"
},
"name": "topp"
}
]
}
],
"lastModified": "2017-01-18 19:02:38.0 UTC",
"name": "workspaces",
"parent": {
"link": {
"href": "http://localhost:8080/geoserver/rest/resource/",
"rel": "alternate",
"type": "application/json"
},
"path": "/"
}
}
}
Observe the child
element. For single-element arrays, Jetison 1.0.1 wraps the single entry in an array. With Jettison 1.2, the wrapping array is removed.
For multi-element arrays, the Jettison 1.0.1 and Jettison 1.2 encodings are the same, except for the addition of the top-level array discussed above.
Note that the Jettison 1.2 encoding is probably more correct than the current Jettison 1.0.1 encoding. Neither encoding is especially good, but that is mostly a side effect of trying to output an XStream document as JSON.
Project Steering Committee:
- Alessio Fabiani:
- Andrea Aime:
- Ben Caradoc-Davies:
- Brad Hards:
- Christian Mueller:
- Ian Turton:
- Jody Garnett:
- Jukka Rahkonen:
- Kevin Smith:
- Simone Giannecchini:
- Email Discussion
- Discussion of Library upgrade (2017-01-31). (The thread is fragmented on sourceforge; search for the subject line.)
- Initial Pull Request - https://github.com/geoserver/geoserver/pull/2072
- Jira issue: To be created
- Related issues:
©2020 Open Source Geospatial Foundation