Hi.
Background:
- Unity 2020.3.24f1 LTS
- ES3 3.4.0
1. Saves 'array' or 'list' as an 'object' type via ES3.Save(key, value) in cache.
more exactly it is originally a type of 'System.Collection.Generic.List'
(e.g. System.Collections.Generic.List`1[System.Boolean])
2. Error will occur when I load them from cache (cache that loaded file's data).
Problem:
- ES3JSONReader throws (FormatException: Expected '{' or "null", found '['. )
I think It cannot read object as Collection if I load object type from cache.
Full Error Stack:
Data that occured error:
It would be nice if you could solve this quickly. It is urgent because we need to ship this until tomorrow.
With regards.
Load type of 'object' from the location of 'cache' will not work properly if it was originally a collection(or a list).
Re: Load type of 'object' from the location of 'cache' will not work properly if it was originally a collection(or a lis
Hi there, and thanks for getting in contact.
This is expected behaviour if you're telling it to save and load it as a System.Object. Although the data inherits from System.Object, it's type is not System.Object and therefore can't be deserialised as such (System.Object has no fields).
In this case you would either need to save it without 'object' as the generic parameter, or load it using ES3.Load<List<bool>>, or both. Otherwise it's impossible for any serialiser to know that you want to load it as anything other than a System.Object.
I.e. this will not work:
But this will work:
And this will work:
All the best,
Joel
This is expected behaviour if you're telling it to save and load it as a System.Object. Although the data inherits from System.Object, it's type is not System.Object and therefore can't be deserialised as such (System.Object has no fields).
In this case you would either need to save it without 'object' as the generic parameter, or load it using ES3.Load<List<bool>>, or both. Otherwise it's impossible for any serialiser to know that you want to load it as anything other than a System.Object.
I.e. this will not work:
Code: Select all
var list = new List<bool>(new bool[]{ true, false, true, false });
var settings = new ES3Settings(ES3.Location.Cache);
ES3.Save<object>("list", list, settings);
object newList = ES3.Load<object>("list", settings);
Debug.Log(((List<bool>)newList).Count);
Code: Select all
var list = new List<bool>(new bool[]{ true, false, true, false });
var settings = new ES3Settings(ES3.Location.Cache);
ES3.Save("list", list, settings);
object newList = ES3.Load<object>("list", settings);
Debug.Log(((List<bool>)newList).Count);
Code: Select all
var list = new List<bool>(new bool[]{ true, false, true, false });
var settings = new ES3Settings(ES3.Location.Cache);
ES3.Save("list", list, settings);
object newList = ES3.Load<List<object>>("list", settings);
Debug.Log(((List<bool>)newList).Count);
Joel