Question

I was playing around with scriptCS and testing some functions in the REPL. I've noticed that when i return a dictionary there is a key value pair of "$id" : "1".

For Example this dictionary:

var types = new Dictionary<string, int>();
types.Add("smokey", 1);
types.Add("streaky", 1);
types.Add("kevin", 1);

Will return this in the REPL.

{
  "$id": "1",
  "smokey": 1,
  "streaky": 1,
  "kevin": 1,
}

I would like to know what the purpose of $id is, how I would access it and what I would use it for.

Was it helpful?

Solution

It is inserted into the object by JSON.net when serializing the object to JSON for on-screen display. This is discussed in an issue on GitHub. It was put into place to fix other issues that had previously caused scriptcs to crash when serializing issues, and it doesn't look like they are going to change it since it doesn't hurt anything.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top