我有一个string格式的JSON 。 我需要将它存储在key-pair值或类似的东西中。 我使用的是asp.net 2.0 ,不能像Newtonsoft.Json.dll那样使用第三方DLL 。 我想最后的选择将是使用regular expression 。
任何人都可以帮助我吗?
I have one JSON that is coming in a string format. I need to store it in a key-pair value or something like that. I am using asp.net 2.0 and can not use 3rd party DLL like Newtonsoft.Json.dll. I guess last option will be to use regular expression.
Can anybody please help me in this?
最满意答案
如果您访问http://www.json.org/并查看页面底部,则会有几十个json库,其中大多数是开源的,我相信它们会列出C#的8个。 如果您不能参考这些库中的一个,我认为您最好的选择是找到一个拥有许可许可证的人,并简单地将代码添加到您的项目中。
另一个想法是在http://www.json.org/查看图表,语法和语法,然后编写自己的解析器,但是正则表达式不是这样做的。 如果你不知道如何编写解析器,你可以看看其中一个开源的json库或者像一个好的CSV解析器那样简单的东西开始,这里有一篇看起来很不错的文章: http : //www.boyet.com /Articles/CsvParser.html
If you go to http://www.json.org/ and look towards the bottom of the page there are dozens of json libraries most of them open source, I believe they list 8 for C#. If you can not reference one of these libraries, I think your best bet would be to find one with a permissive license and simply add the code to your project.
Another idea is to look at the diagrams, grammer, and syntax at http://www.json.org/ and just write your own parser, but regex is NOT the way to do it. If you dont know how to write a parser you could look at one of the open source json libraries or start with something less complicated like a good CSV parser, here is a paper that looks pretty good: http://www.boyet.com/Articles/CsvParser.html
更多推荐
发布评论