0 votes

Hello.
I program a little game, where the data is taken from json-files.
I can load, edit and save a json in the program like a in-built json-editor (scene with buttons and a textedit to view and edit the json).
The JSON-Files are big and i must use paragraphs to have an overview. In Wordpad/Notepad++ this is easy, but when after i save the json with the in-built-editor, the json is 1 line of code. I want to make paragraphs and when i save it, it should be there when i load.
How can i do that?

Godot version 3.2.3
in Engine by (17 points)

1 Answer

0 votes

It's not possible. JSON is meant to be single line values. If you want line breaks, you'll need to find a software that will automatically create them from the new line marker.

by (26 points)
edited by

This question again passed my view and I just had an idea. I just thought of it and haven't tried it yet, but what if you saved both a JSON and a txt file? The JSON could be a single line which you don't touch, but the txt could include line breaks and be the one you modify. Then when loading it into Godot, you could just check which one is more recent and load that one. Or depending how many keys your JSON files have, you could save each one as a text file, then load them each back in individually, parsing the line breaks to "\n", then setting them to the value of their respective key.

I'll try this and report my results.

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.