Im using LoadJsonFromFile to attempt to load a JSON file in blueprint, but I am failing. Is it not possible to load JSON with arrays?
My JSON is:
[
{
"Type": "TypeA",
"Name": "NameA"
},
{
"Type": "TypeB",
"Name": "NameB"
}
]
1 Like
Wrap your json text manually in an object before sending it to the parser :
Thank you, that did sort of help, but I get this message “LogJson: Warning: Ignoring excess properties when deserializing CallFunc_GetField_OutValue” and its not clear to me how I would get the TypeB/NameB fields in the second array element. Need a way to do a foreach loop over the JSON array…
The result of parser is a JsonObject, with a single element “array” inside it.
When you use GetField, the result pin is a wildcard, because it can theoretically be any type of json value.
Here your result is a JsonArray, but blueprints don’t support JsonArray. However JsonArray is interchangeable with Array of JsonObject so you can use that in blueprints. You cannot use Foreach on the result directly, because Foreach uses wildcard pin too, and bp compiler cannot infer the type over multiple nodes. So the solution is to create a variable of type Array(JsonObject) and store the result into that so the compiler can infer the type. Then you can use Foreach on it.
3 Likes