godotengine / godotengine/godot-docs

How to save and read pretty printed Json

Open
#5,513 1 comment 2 reactions 0 assignees View on GitHub
area:class reference enhancement
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Your Godot version:**
3.4
**Issue description:**
I had the problem that I wanted to read my saved json file manually and with my program.
I couldn't find any instructions on the internet how to do that and I think it should be added to the json part of the documentation to make it easier for a programmer to debug the json file.
````
Json-File:
{
"setting": "1",
"another_setting": 1234
}
Godot variable:
{setting:1, another_setting:1234}
(String) (Int)
````

Save Json:
````
var save_file = File.new()
save_file.store_line(JSON.print({"setting":"1","another_setting":1234},"\t"))
````
Load Json:
````
var load_file = File.new()
var data= parse_json(load_file.get_as_text())
````
**URL to the documentation page (if already existing):**
https://docs.godotengine.org/de/stable/classes/class_json.html#class-json-method-print

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.