json file didn't work in android

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cnkids

Already add *.json to non-resource export filter. But it didn’t work.
Windows and Test work well.
enter image description here

rename to txt and remove import settings and it should work

rakkarage | 2020-08-22 20:13

still not work.

var jsonPath = “res://hit.txt”
func read_json():
jsonFile = read_file(jsonPath)
if jsonFile:
jsonTxt = parse_json(jsonFile)

terminal can print
enter image description here

and where is “remove import settings”?

cnkids | 2020-08-23 02:56

ya sorry i guess i was thinking of csv files, when you create one in project directory it makes a “test.csv.import” file and does not load on android unless rename to txt and remove
import Godot can't load CSV file as TextFile resource · Issue #38245 · godotengine/godot · GitHub

rakkarage | 2020-08-23 14:27

Thank you for your help so much.
At last the problem I found was that the fonts file was named in Chinese, which may have caused the path to be read incorrectly.
Now the problem solved.

cnkids | 2020-08-23 17:07

:bust_in_silhouette: Reply From: Axolotl

I was facing the same issue today. After googling for a while, I found out that there is an open issue associated with imported CVS files while running the project in Android.

I don’t know if this is related to .json files, but as a workaround, I did what @rakkarage suggested.

I changed the extension to .txt

txt extension

In my code, I also updated the function that opens the file

txt extension

And just in case I added a filter for .txt files to export the project to Android

txt extension

After this, you should be able to use .json files in Android projects

:bust_in_silhouette: Reply From: Mr.RZ

I recently had the same issue with json file, so I’m putting this here for those who come across the same issue.

I just replaced “res://” with “user://”, but now only works with android not in pc. So anyway problem is with in that part.