Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] JSON and text files problems

Author
Message
MadTinkerer
7
Years of Service
User Offline
Joined: 21st Nov 2010
Location:
Posted: 11th Jul 2018 17:57
I'm trying to use toJSON and fromJSON to maintain a settings file that can be manually edited by humans (mostly for testing purposes) but which my program will also read on startup and write when the user changes the settings in the (not yet created) settings menu. Ideally I would like to save several JSON records as individual strings in the one text file, but at the moment I only have one string I'm trying to save, because even that isn't working yet.

Here is my problem code:



displaySettings is a global record that holds a bunch of info used by ApplyDisplaySettings() to set the screen width and height and so on. These two functions return settingsString because I needed to figure out why I kept getting the message "unexpected end of object" when I ran LoadSettings. SaveSettings seems to work just fine: it saves a human-readable string to a text file that represents the displaySettings record. LoadSettings seems to load the first bracket, but not the rest of the string. It seems to literally read "{" instead of the whole string.

The author of this post has marked a post as an answer.

Go to answer

MadTinkerer
7
Years of Service
User Offline
Joined: 21st Nov 2010
Location:
Posted: 11th Jul 2018 18:23
This post has been marked by the post author as the answer.
Aha! I figured it out. I was using writeline and readline instead of writestring (or writestring2) and readstring (or readstring2). Writeline looked like it was doing what I wanted, but I really needed to use writestring and readstring instead.

Login to post a reply

Server time is: 2018-09-18 23:09:50
Your offset time is: 2018-09-18 23:09:50