Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net IronPython-JSON选项_.net_Json_Ironpython_Dynamic Language Runtime - Fatal编程技术网

.net IronPython-JSON选项

.net IronPython-JSON选项,.net,json,ironpython,dynamic-language-runtime,.net,Json,Ironpython,Dynamic Language Runtime,在IronPython 2.0.1中处理JSON的最佳方法是什么。本地Python“标准库”json看起来还没有实现 如果我想使用Newtonsoft Json.NET库,我该怎么做?我可以将程序集添加到GAC,但我的其他选择是什么 此链接概述了使用IronPython向.Net DLL添加引用的方法: 因此,例如,如果您希望避免将Json.NET库放在GAC中,您可以使用 导入clr clr.AddReferenceToFile(“jsonnet.dll”) 或 clr.AddReferenc

在IronPython 2.0.1中处理JSON的最佳方法是什么。本地Python“标准库”json看起来还没有实现


如果我想使用Newtonsoft Json.NET库,我该怎么做?我可以将程序集添加到GAC,但我的其他选择是什么

此链接概述了使用IronPython向.Net DLL添加引用的方法:

因此,例如,如果您希望避免将Json.NET库放在GAC中,您可以使用

导入clr
clr.AddReferenceToFile(“jsonnet.dll”)

clr.AddReferenceToFileAndPath(“C:\\libraries\\jsonnet.dll”)

#list with data
data=[]
item={}
item["name"]="joe's pizza"
item["tel"] = "343-4333"
data.append(item)

#returns: [{'tel': '343-4333', 'name': "joe's pizza"}] 
#but not valid JSON 
print str(data) 

#returns [{"tel":"343-4333","name":"joe\u0027s pizza"}]
import clr
clr.AddReference('System.Web.Extensions')
from System.Web.Script.Serialization import JavaScriptSerializer #since .net 3.5?
json=JavaScriptSerializer().Serialize(data)
print str(json)