immersivecognition / unity-experiment-framework

UXF - Framework for creating human behaviour experiments in Unity
https://immersivecognition.github.io/unity-experiment-framework/
MIT License
223 stars 44 forks source link

saving dictionaries (same as lists?) #124

Closed trentwirth closed 2 years ago

trentwirth commented 2 years ago

I'm working on a project using UXF (thank you, it's great!) and I stumbled across this quirk that I wanted to better understand, because it seemed like a mistake but maybe it isn't:

to save a List or a Dictionary, you use the same method, "trial/session.HandleJSONSerializableObject". I'm learning c# mostly via working my way through UXF and other tutorials, but I was wondering if this was intentional, and if so, why?

Thanks!

jackbrookes commented 2 years ago

Hi! Glad you like UXF. This is intentional because these methods are designed to save data in a JSON-like format.

https://en.wikipedia.org/wiki/JSON#Syntax

JSON can be either a list or a dictionary in C# terms. You can have lists of objects, numbers, strings, or dictionaries, or even dictionaries of lists, other dictionaries, etc. UXF will save them all.

If you want to save a literal "list" of values you may be better of saving a UXFDataTable, which is data in the structure of a spreadsheet.

trentwirth commented 2 years ago

awesome, good to know! happy to learn!

cheers