im trying to import a json file to a data table
this is the format
{“type”:“Feature”,“geometry”:{“type”:“LineString”,“coordinates”:[[0.1334377,51.8762538],[0.1334907,51.8762944],[0.1335747,51.8763408],[0.1335953,51.87635],[0.1336031,51.8763534],[0.1337372,51.8763838],[0.1338624,51.8763957],[0.1340255,51.8763887],[0.134184,51.8763458],[0.1343079,51.8762871]]},“properties”:{“osm_id”:“3988226”,“code”:5112,“fclass”:“trunk”,“name”:“”,“ref”:“”,“oneway”:“F”,“maxspeed”:96,“layer”:0,“bridge”:“F”,“tunnel”:“F”}},
what would the struct look like ?
i had assumed (probably wrongly) that it would be something like this
@ozbitme
I can’t say I see a major flaw in the design of your struct at all, you just need to be making sure you have the correct data types for all your variables.
I found a pretty good step-by-step guide if you need any help with the process too:
I hope this can help, and let me know if you have more questions!
-Zen
I don’t think you can parse the bi-dimensional coordinates array into a blueprint struct as-is. You might have to rework the data to convert that into an array of FVector2D.
Then you will probably have to setup a proper nested struct like this (or in blueprint form), to match your json structure :
To convert your data there are various approaches.
If it’s just one time seeding you can pass it thru search & replace with any text editor that supports regexp, eg. Notepad++
If you are getting it dynamically via eg. webrequests then you probably have a C++ side that can handle this much better than blueprints. You can do something similar as above in C++, or alternatively parse your json object into a FJsonObject via the engine Json utilities, then alter the object to replace the bidimensional array with an array of objects.
While you are at it you might also want to convert those string-booleans into real booleans… “F” → false and “T” → true (I guess), then change corresponding struct properties to boolean instead of string.