Hi Dear Community,
I’m trying to do a JsonParserfor Typescript, by this way.
Thats not working, but it prints loading Json. I think it is because the callback function is running after the function make the return. Do you know what is going on?
Whats the correct way to parse a Json file to a Typescript array objects?
i didn’t spend too much team reading your code but if you get “loading Json” in the console, why not put a break point there and see what is inside your err and res values?
The problem reside in the asynchronous function ((err, ress) => {… } ). When the function do the return, the anonymous function part is not executed yet. So always return null. I’m learning about this theme right now, so i think i will solve this in a few hours/days. Anyway i think cocos must have any another way to do this like map Json attributes with an typescript object. But i don’t found any information about that, so i’m implementing my own way.