json import struct

im trying to import a json file to a data table
this is the format

what would the struct look like ?
i had assumed (probably wrongly) that it would be something like this

gis_osm_roads_free_1json.json (1.7 MB)

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!

1 Like

it may be a format issue as its giving me an error with no code or info
thanks tho

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 :

struct FGeometry {
    FString type;
    TArray<FVector2D> coordinates;

struct FProperties {
    FString osm_id;
    int32 code;
    FString fclass;
    FString name;
    FString ref;
    FString oneway;
    int32 maxspeed;
    int32 layer;
    FString bridge;
    FString tunnel;

struct FResult {
    FString type;
    FGeometry geometry;
    FProperties properties;

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++

search  :    \[([0-9.]+), ([0-9.]+)\]
replace :    {"X":$1, "Y":$2}

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.