Nested keys?

Discussion and help for Easy Save 3
Post Reply
Rogerio
Posts: 8
Joined: Sat Nov 14, 2020 8:29 am

Nested keys?

Post by Rogerio »

Can I create nested keys?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Nested keys?

Post by Joel »

Hi there,

Nested keys aren't possible. However, you could create two separate keys and achieve the same thing. For example you could have a key named "parentKey" and then a key named "parentkey_childkey".

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Rogerio
Posts: 8
Joined: Sat Nov 14, 2020 8:29 am

Re: Nested keys?

Post by Rogerio »

Not the same because if I deleted "parentkey" then "parentkey_child" would still exist.
I was hoping to cut my work short.
Unless there's a way i can delete every key starting with "parentkey"?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Nested keys?

Post by Joel »

Hi there,

Key/value collections do not work in this way unfortunately, much in the same way that you can't have nested keys in a C# dictionary. If you wish to nest data in this way then you would need to create a class which represents that structure. For example:

Code: Select all

public class Parent
{
    public string child;
}
And then save:

Code: Select all

ES3.Save("parentKey", myParentClass);
Then to load:

Code: Select all

string child = ES3.Load<Parent>("parentKey").child;
And to delete:

Code: Select all

ES3.DeleteKey("parentKey");
Hope this helps.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply