What is the $id property shown in ScriptCS when viewing an object in the REPL?

StackOverflow https://stackoverflow.com/questions/21850846

  •  13-10-2022
  •  | 
  •  

Frage

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.

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top