FormatException: Expected quotation mark, found '{'

Discussion and help for Easy Save 3
Post Reply
Alex-B
Posts: 2
Joined: Sun Oct 03, 2021 12:50 am

FormatException: Expected quotation mark, found '{'

Post by Alex-B »

My problem is that whenever I load my values and prefabs, I get the error:

Code: Select all

FormatException: Expected quotation mark, found '{'.
ES3Internal.ES3JSONReader.ReadQuotationMarkOrNullIgnoreWhitespace () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:397)
ES3Internal.ES3JSONReader.Read_string () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:497)
ES3Internal.ES3JSONReader.ReadPropertyName () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:65)
ES3Reader+ES3ReaderPropertyEnumerator+<GetEnumerator>d__2.MoveNext () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:414)
ES3Types.ES3Type_GameObject.ReadObject[T] (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:139)
ES3Types.ES3ObjectType.ReadInto[T] (ES3Reader reader, System.Object obj) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:77)
ES3Types.ES3Type_GameObject.ReadObject[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Unity Types/ES3Type_GameObject.cs:131)
ES3Types.ES3ObjectType.Read[T] (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/ES3ObjectType.cs:54)
ES3Reader.ReadObject[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:249)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:278)
ES3Types.ES3CollectionType.ReadICollection[T] (ES3Reader reader, System.Collections.Generic.ICollection`1[T] collection, ES3Types.ES3Type elementType) (at Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3CollectionType.cs:52)
ES3Types.ES3ArrayType.Read (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3ArrayType.cs:36)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:274)
ES3.Deserialize (ES3Types.ES3Type type, System.Byte[] bytes, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:799)
ES3.Deserialize[T] (System.Byte[] bytes, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:788)
ES3File.Load[T] (System.String key, T defaultValue) (at Assets/Plugins/Easy Save 3/Scripts/ES3File.cs:246)
ES3.Load[T] (System.String key, T defaultValue, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:433)
ES3AutoSaveMgr.Load () (at Assets/Plugins/Easy Save 3/Scripts/Auto Save/ES3AutoSaveMgr.cs:85)
ES3AutoSaveMgr.Awake () (at Assets/Plugins/Easy Save 3/Scripts/Auto Save/ES3AutoSaveMgr.cs:104)
Only my values (ints, floats, etc) actually load, and my prefabs don't. I don't understand what the problem is though, here's my code for saving and loading:

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SaveAndLoadValues : MonoBehaviour
{
    [SerializeField] private ES3AutoSaveMgr es3asm;

    private float money;
    private int population;
    private float polution;
    private float happiness;
    private float fatness;

    void Start()
    {
        Load();
    }

    public void Save()
    {
        ES3.Save("money", MainNumberManager.money, "MainValues.txt");
        ES3.Save("population", MainNumberManager.population, "MainValues.txt");
        ES3.Save("polution", MainNumberManager.polution, "MainValues.txt");
        ES3.Save("happiness", MainNumberManager.happiness, "MainValues.txt");
        ES3.Save("fatness", MainNumberManager.fatness, "MainValues.txt");

        es3asm.Save();
    }

    public void Load()
    {
        money = ES3.Load<float>("money", "MainValues.txt");
        MainNumberManager.money = money;
        population = ES3.Load<int>("population", "MainValues.txt");
        MainNumberManager.population = population;
        polution = ES3.Load<float>("polution", "MainValues.txt");
        MainNumberManager.polution = polution;
        happiness = ES3.Load<float>("happiness", "MainValues.txt");
        MainNumberManager.happiness = happiness;
        fatness = ES3.Load<float>("fatness", "MainValues.txt");
        MainNumberManager.fatness = fatness;

        es3asm.Load();
    }

    void OnApplicationQuit()
    {
        Save();
    }
}
I have a few buttons that call the Save() function, and I have some scene switching, but the problem only occurs when I try to load.

Any help is really appreciated, thanks :) .
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: FormatException: Expected quotation mark, found '{'

Post by Joel »

Hi there,

The error is being thrown by Auto Save, not the code you have linked.

Just to check, have you tried deleting your previous save data? You can do this by going to Tools > Easy Save 3 > Clear Persistent Data Path.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Alex-B
Posts: 2
Joined: Sun Oct 03, 2021 12:50 am

Re: FormatException: Expected quotation mark, found '{'

Post by Alex-B »

Hey,

Thank you! I cleared the Persistent Data Path and then looked around a bit more in the autosave section and found the problem.

Thanks for the help again :D .
Artur
Posts: 2
Joined: Thu Mar 31, 2022 4:06 am

Re: FormatException: Expected quotation mark, found '{'

Post by Artur »

Hello,
I'm having the same error, how did you solve it?

Sometimes the error is replaced by this one

Code: Select all

FormatException: Expected '}', found ']'.
ES3Internal.ES3JSONReader.ReadCharIgnoreWhitespace (System.Char expectedChar) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:374)
ES3Internal.ES3JSONReader.EndReadObject () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:116)
ES3Reader.ReadObject[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:251)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:278)
ES3Types.ES3CollectionType.ReadICollection[T] (ES3Reader reader, System.Collections.Generic.ICollection`1[T] collection, ES3Types.ES3Type elementType) (at Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3CollectionType.cs:52)
ES3Types.ES3ArrayType.Read (ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Types/Collection Types/ES3ArrayType.cs:36)
ES3Reader.Read[T] (ES3Types.ES3Type type) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:274)
ES3Reader.Read[T] (System.String key, T defaultValue) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:212)
ES3.Load[T] (System.String key, T defaultValue, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:419)
ES3AutoSaveMgr.Load () (at Assets/Plugins/Easy Save 3/Scripts/Auto Save/ES3AutoSaveMgr.cs:81)
ES3AutoSaveMgr.Awake () (at Assets/Plugins/Easy Save 3/Scripts/Auto Save/ES3AutoSaveMgr.cs:100)
My save file has more than 7000 lines, would it be an issue? I have cleared the data path multiple times but I have no idea why it is failing to load the file properly
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: FormatException: Expected quotation mark, found '{'

Post by Joel »

Hi there,

This error is usually caused because a field is being loaded as the wrong type. For example, because the field was previously an object type but is now a string.

If you replicate your issue in a new project with a simple scene and private message it to me with instructions I’m happy to look into it further.

Also if you private message me your invoice number, I can send over an upcoming update which resolves a rare case which can cause this error, just in case.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Artur
Posts: 2
Joined: Thu Mar 31, 2022 4:06 am

Re: FormatException: Expected quotation mark, found '{'

Post by Artur »

Hello,

Since the scene is a bit large with tons of objects, it was a little hard for me to find the object (or objects) with the wrong field. So I removed everything from everybody and set the autosave again from scratch.
While I was doing so, I noticed that when I uncheck the components of an object on the AutoSave window, it does not remove the autosave script from the corresponding object in the scene. My guess is that I had some objects with the autosave script that were not checked at the AutoSave window and that could be leading to this "field being loaded as the wrong typee" situation.

In any case I have everything working again. I will check the info you requested and will message you shortly after.

Thanks for the help!
Cheers
Post Reply