如何使Newtonsoft.Json.Linq.JObject不可变? [英] How to make Newtonsoft.Json.Linq.JObject immutable?

查看:198
本文介绍了如何使Newtonsoft.Json.Linq.JObject不可变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以创建JObject

I can create JObject

var jobject = Newtonsoft.Json.Linq.JObject.Parse(jsonstring);

我想将jobject转换为只读,以便不能添加新键或修改现有值.

I want to convert the jobject read only so that no new keys can be added or existing values modified.

推荐答案

无法完成.实施它存在一个未解决的问题:

It can't be done. There is an open issue for implementing it:

https://github.com/JamesNK/Newtonsoft.Json/issues/468

但是它已经两岁了,据我所知,它几乎没有引起人们的注意.

But it is two years old and has drawn very little attention as far as I can tell.

这篇关于如何使Newtonsoft.Json.Linq.JObject不可变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆