0 votes

I thought saving to json with open was supposed to save as a text.json but mine is saving as encrypted or something.

I created a pastebin this time, The Code Sample always breaks on me

pastebin name SaveJson_SavesWrongData:


my json var:
onready var thingtosave = {
"parent": "minecraft:item/generated",
"textures": {
"layer0": "minecraft:item/"+str(NewName)

What gets saved to the json file:
5c00 0000 0400 0000 5100 0000 7b22 7061
7265 6e74 223a 226d 696e 6563 7261 6674
3a69 7465 6d2f 6765 6e65 7261 7465 6422
2c22 7465 7874 7572 6573 223a 7b22 6c61
7965 7230 223a 226d 696e 6563 7261 6674
3a69 7465 6d2f 4e75 6c6c 227d 7d00 0000

if im not mystaken, godot is encrypting the data. even though i use open and not open_encrypted

any help would be much appreciated :)

Godot version 3.5beta1
in Engine by (58 points)

i fixed it by changing from store_var to store)line.

but now it prints all in one line and does not look good at all lol.

any ideas on how to fo fix this????

i didnt want to do this but i ended up seperating each line in the json file and printing them seperately.

i would rather have a few nasty lines of code then have thousand of files that are hard to read.

this is my new save function and it PrettyPrints each json file.

func Save(PATH : String,NewName, thing_to_save):
var file = File.new()
var MIGenerated = "minecraft:item/generated"
file.open(PATH+NewName+".json", File.WRITE)
#file.store_line(to_json(thing_to_save)) #Works but all in 1 line
file.store_line('\t\t"textures": {')
file.store_line('\t\t"layer0": '+str(NewNewName)+'"')

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.