godotengine / godotengine/godot-docs
Add loading a JSON file to documentation
- Dominant language
- reStructuredText
- Stars
- 5.7k
- Forks
- 3.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 25
Description
**Your Godot version:**
Godot 4.2
**Issue description:**
I'm working on using a JSON file and wanted to figure out how to load and parse a JSON file.
Perhaps we could have a reference to [FileAccess](https://docs.godotengine.org/en/stable/classes/class_fileaccess.html) or provide an example when using a JSON file? I think some beginners would benefit from this because it is more likely we end up using a JSON file than just creating a JSON from the engine (as per the example provided in the documentation).
If we will do an example, maybe it would be something like
```gdscript
func read_json(json_path):
# Retrieve file
var file = FileAccess.open(json_path, FileAccess.READ)
var content = file.get_as_text()
# Parse JSON
var json = JSON.new()
var result = json.parse_string(content)
return result
```
It could also benefit from a C# version of the code.
**URL to the documentation page (if already existing):**
https://docs.godotengine.org/en/stable/classes/class_json.html
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.