How to import my JSON file data into JS file

Hi guys
I have a concern I would like to make a drop-down menu that will display the list of country indicators. I have a JSON file with all the indicators, their flags and names of each country, I was able to make the dropdown menu and I would like to display the data contained in the JSON file in my dropdown menu.


Here is my .JSON file



Here is my file in JS where I create the selection in my dropdown menu

Thank you in advance please help me

you can refer to: JSON · Cocos Creator

Could you show your demo, and show the final result you want?

In a logic that I would like to make a drop-down menu to display and make a choice on the countries for the player, here it is

I would like to display the information contained in the JSON file in the Dropdown Menu

hey guys

You can refer to document i metioned before to get JSON data from JSON file , then to set data to the Dropdown Menu.

Hi, CocosCreator 3.5.0 already supports importing json in ts. You can do what I did by using.

can I do that in Cocos Creator 2.4.5? I’ve tried it, but in the console showing error message “Cannot find module”

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.