"FormatException: File is not valid JSON." error

Discussion and help for Easy Save 3
Post Reply
hawken
Posts: 12
Joined: Fri Mar 02, 2018 6:50 am

"FormatException: File is not valid JSON." error

Post by hawken »

I'm getting the following warning when using ES3, easy save functions are not working while this appears

Code: Select all

FormatException: File is not valid JSON. Expected '{' at beginning of file, but found '
ES3Internal.ES3JSONReader.SkipOpeningBraceOfFile () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:473)
ES3Internal.ES3JSONReader..ctor (System.IO.Stream stream, .ES3Settings settings, Boolean readHeaderAndFooter) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:33)
UnityEngine.EventSystems.EventSystem:Update()
Is there a way to get this back on track?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: "FormatException: File is not valid JSON." error

Post by Joel »

Hi Hawken,

First, try deleting your save file and see if this fixes the issue. It could be that there's still data in the file from the previous update I sent you. You can clear all of your save data by going to Window > Easy Save 3 > Tools > Clear Default Save Folder.

If this does not fix your issue, please could you provide me with steps or a basic project to replicate it?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
chrisv007
Posts: 6
Joined: Mon Apr 15, 2019 12:57 pm

Re: "FormatException: File is not valid JSON." error

Post by chrisv007 »

Hi, I'm having the same issue but only when encryption is activated. It seems that the system does not know that the file is encrypted?
For now I'll deactivate the encryption but I would like to reactivate it before I publish the game for security reasons.
Chris Verner
Chris Verner Studio
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: "FormatException: File is not valid JSON." error

Post by Joel »

chrisv007 wrote:Hi, I'm having the same issue but only when encryption is activated. It seems that the system does not know that the file is encrypted?
For now I'll deactivate the encryption but I would like to reactivate it before I publish the game for security reasons.
Hi there,

There are many reasons why this error message can be caused. Please could you show me the code you are using so I can try to establish why this is happening? Otherwise I have no information to go on.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
chrisv007
Posts: 6
Joined: Mon Apr 15, 2019 12:57 pm

Re: "FormatException: File is not valid JSON." error

Post by chrisv007 »

Joel wrote:
chrisv007 wrote:Hi, I'm having the same issue but only when encryption is activated. It seems that the system does not know that the file is encrypted?
For now I'll deactivate the encryption but I would like to reactivate it before I publish the game for security reasons.
Hi there,

There are many reasons why this error message can be caused. Please could you show me the code you are using so I can try to establish why this is happening? Otherwise I have no information to go on.

All the best,
Joel
Hi,

I tried encrypting the save file again this morning and this is the error I get:
FormatException: File is not valid JSON. Expected '{' at beginning of file, but found '�'.
ES3Internal.ES3JSONReader..ctor (System.IO.Stream stream, ES3Settings settings, System.Boolean readHeaderAndFooter) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:39)
ES3Reader.Create (ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:314)
ES3.Load[T] (System.String key, T defaultValue, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:303)
ES3AutoSaveMgr.Load () (at Assets/Plugins/Easy Save 3/Scripts/Auto Save/ES3AutoSaveMgr.cs:42)
ES3AutoSaveMgr.Awake () (at Assets/Plugins/Easy Save 3/Scripts/Auto Save/ES3AutoSaveMgr.cs:56)
If I don't enable encryption, everything works perfectly. I save info at multiple places in the game.

Hope this helps
Thanks
Chris Verner
Chris Verner Studio
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: "FormatException: File is not valid JSON." error

Post by Joel »

Hi Chris,

The error message you mentioned happens if you try to load encrypted data when encryption is disabled. Are you certain encrypted is enabled?

Please could you PM me a basic project which replicates it, or show me the script you're using to save and load if you're enabling encryption manually?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
rizawerks
Posts: 5
Joined: Fri Oct 23, 2015 3:52 pm

Re: "FormatException: File is not valid JSON." error

Post by rizawerks »

Hi,
I'm trying to run upload and download prefab as mentioned in https://moodkie.com/forum/viewtopic.php?f=16&t=1436
I have done cloud settings and it says succsess..I also have change the cloud an api keys but every time i run the sample scene it always said :

FormatException: File is not valid JSON. Expected '{' at beginning of file, but found '&'.
ES3Internal.ES3JSONReader..ctor (System.IO.Stream stream, ES3Settings settings, System.Boolean readHeaderAndFooter) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:39)
ES3Reader.Create (ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:322)
ES3.Load[T] (System.String key, T defaultValue, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:306)
ES3AutoSaveMgr.Load () (at Assets/Plugins/Easy Save 3/Scripts/Auto Save/ES3AutoSaveMgr.cs:43)
ES3AutoSaveMgr.Awake () (at Assets/Plugins/Easy Save 3/Scripts/Auto Save/ES3AutoSaveMgr.cs:57)

I tried clear persistent data path, tried enable / disable encryiption but none is working....
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: "FormatException: File is not valid JSON." error

Post by Joel »

Hi there,

The error shows that the data being returned by the server isn't in JSON format. This could be for a number of reasons:
  • The server is trying to apply the incorrect encoding to the data
  • The data is encrypted when it's sent to the server, but encryption isn't enabled for Auto Save
  • The file uploaded wasn't created using Easy Save
Please could you create a basic project which replicates this and private message it to me so I can try to understand what is happening?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
rizawerks
Posts: 5
Joined: Fri Oct 23, 2015 3:52 pm

Re: "FormatException: File is not valid JSON." error

Post by rizawerks »

Joel wrote:Hi there,

The error shows that the data being returned by the server isn't in JSON format. This could be for a number of reasons:
  • The server is trying to apply the incorrect encoding to the data
  • The data is encrypted when it's sent to the server, but encryption isn't enabled for Auto Save
  • The file uploaded wasn't created using Easy Save
Please could you create a basic project which replicates this and private message it to me so I can try to understand what is happening?

All the best,
Joel
Hi, after some research, i found the problem..
the problem is in ES3Variables.php ( after installed ES3Cloud.php )
I don't know why, but the header of ES3Variables start with '<?php' intead of '<?php' and also the end is '?> instead of '?>'
So I simply change ES3Variables.php, change the header and the end and put it back to my host...then it's working.
Thanks,
Post Reply