g3w-suite / g3w-admin

Server module for G3W-SUITE
https://g3w-suite.readthedocs.io/en/latest/g3wsuite_administration.html
Mozilla Public License 2.0
39 stars 31 forks source link

JSON response outputs `"NULL"` instead of `null` when `formatter: 1` #794

Open Raruto opened 3 months ago

Raruto commented 3 months ago

Checklist

Subject of the issue

Null values are converted to string when sent to HTTP response (formatter: 1) causing an inconsistent handling in JS code:

image

Steps to reproduce

"formatter": 1

// outputs: "NULL"

fetch('https://v37.g3wsuite.it/vector/api/data/qdjango/97/buildings_2f43dc1d_6725_42d2_a09b_dd446220104a/', {
  method: 'POST',
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "field": "type|eq|Administrative",
    "formatter": 1,
  }),
}).then(d => d.json()).then(d => console.log(d.vector.data.features[4].properties.subtype))

"formatter": 0

// outputs: null

fetch('https://v37.g3wsuite.it/vector/api/data/qdjango/97/buildings_2f43dc1d_6725_42d2_a09b_dd446220104a/', {
  method: 'POST',
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "field": "type|eq|Administrative",
    "formatter": 0,
  }),
}).then(d => d.json()).then(d => console.log(d.vector.data.features[4].properties.subtype))

Environment

[g3wsdk.info]

Link to your project

https://v37.g3wsuite.it/en/map/demo-37/

Additional info

No response