Hi blackshade,
The purpose of a script item in ClearScript is to allow .NET code to access an actual "live" script object, as opposed to a serialized copy of its data.
Yes, it's definitely faster to read data from a managed collection such as a Json.NET
However, this is very different from what script items do. Some examples:
The purpose of a script item in ClearScript is to allow .NET code to access an actual "live" script object, as opposed to a serialized copy of its data.
Yes, it's definitely faster to read data from a managed collection such as a Json.NET
JObject
or a standard .NET dictionary - and if reading a script object's properties quickly is what you need to do, then we encourage and recommend JSON tunneling. Hopping the boundary between the managed and script environments is expensive, and JSON lets you transfer an entire object's data in one hop.However, this is very different from what script items do. Some examples:
- Writing to a script item modifies the actual script object to which it's bound.
- Unlike JSON, script items provide access to JavaScript properties that are not enumerable.
- Script items invoke property getters and setters as necessary.
- Script items that are functions can be invoked to execute script code.
-
Script items provide access to script objects that aren't JSON-friendly (e.g., VBScript objects).