Newtonsoft.json: Support freezing a JToken

Created on 20 Jan 2015  路  3Comments  路  Source: JamesNK/Newtonsoft.Json

I'd like to propose the ability to "freeze" a JToken. A frozen JToken is essentially read-only; any attempt to change one of its properties results in an InvalidOperationException.

  • The term "a JToken" refers to any instance of a class derived from JToken.
  • When a JToken is initially created, it is not frozen.
  • When a JToken is frozen, all children of the JToken are frozen as well.

No changes would be made to any current public API.

I would be happy to implement this functionality and send a pull request if you like the idea.

Most helpful comment

Any news on this? I just stumbled into a problem which I could solve nicely with immutable JObjects

All 3 comments

This is a little easier now that there is JsonLoadSettings. Could add a flag to that that loaded tokens should be frozen.

Any news on this? I just stumbled into a problem which I could solve nicely with immutable JObjects

Any update with this one?

Was this page helpful?
0 / 5 - 0 ratings