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

JSON: mixed type field not flagged as JSON if first is a string #7313

Closed
elpaso opened this issue Feb 24, 2023 · 0 comments · Fixed by #7315
Closed

JSON: mixed type field not flagged as JSON if first is a string #7313

elpaso opened this issue Feb 24, 2023 · 0 comments · Fixed by #7315
Assignees
Labels

Comments

@elpaso
Copy link
Collaborator

elpaso commented Feb 24, 2023

Also see: qgis/QGIS#51911

{ "type": "FeatureCollection",
  "features": [
    { "type": "Feature",
      "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
      "properties": {"prop0": "astring"}
      },
    { "type": "Feature",
      "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
      "properties": {"prop0": 42}
      },
    { "type": "Feature",
      "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
      "properties": {"prop0": {"nested": 75}}
      }
    ]
  }

ogrinfo -al -q test_string_first.json

OGRFeature(gh_51911_string_first):0
  prop0 (String) = astring
  POINT (102.0 0.5)

OGRFeature(gh_51911_string_first):1
  prop0 (String) = 42
  POINT (102.0 0.5)

OGRFeature(gh_51911_string_first):2
  prop0 (String) = { "nested": 75 }
  POINT (102.0 0.5)

But, moving the string at the second place:

{ "type": "FeatureCollection",
  "features": [
    { "type": "Feature",
      "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
      "properties": {"prop0": 42}
      },
    { "type": "Feature",
      "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
      "properties": {"prop0": "astring"}
      },
    { "type": "Feature",
      "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
      "properties": {"prop0": {"nested": 75}}
      }
    ]
  }

ogrinfo -al -q test_string_second.json

Layer name: gh_51911
OGRFeature(gh_51911):0
  prop0 (String(JSON)) = 42
  POINT (102.0 0.5)

OGRFeature(gh_51911):1
  prop0 (String(JSON)) = astring
  POINT (102.0 0.5)

OGRFeature(gh_51911):2
  prop0 (String(JSON)) = { "nested": 75 }
  POINT (102.0 0.5)
@elpaso elpaso added the bug label Feb 24, 2023
@elpaso elpaso self-assigned this Feb 24, 2023
elpaso added a commit to elpaso/gdal that referenced this issue Feb 24, 2023
rouault pushed a commit that referenced this issue Feb 27, 2023
rouault added a commit that referenced this issue Mar 1, 2023
[Backport release/3.6] GEOJSON: fix mixed type field not flagged as JSON if first occurrence is a string  (fixes #7313)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant