将 JSON 反序列化为 LINQ 对象
在 VB.Net 类中,我有一个 JSON 数据作为字符串。我想将它们转换为 LINQ 类对象。
``
'definition
Dim js As New System.Web.Script.Serialization.JavaScriptSerializer
'return the data
Dim rawdata = js.DeserializeObject(strVal)
' i have this object , generated by LINQ
dim oCustomForm= new CustomForm
'what i need is to Deserialize the string INTO that object
'i tried this....but :(
'Dim oCustomForm As List(Of CustomForm) = CType(rawdata, List(Of CustomForm))
'Dim oCustomForm As new CustomForm = rawdata
`
谢谢....
In VB.Net class, I have a JSON data as string. I want to convert them to LINQ class Object.
`
'definition
Dim js As New System.Web.Script.Serialization.JavaScriptSerializer
'return the data
Dim rawdata = js.DeserializeObject(strVal)
' i have this object , generated by LINQ
dim oCustomForm= new CustomForm
'what i need is to Deserialize the string INTO that object
'i tried this....but :(
'Dim oCustomForm As List(Of CustomForm) = CType(rawdata, List(Of CustomForm))
'Dim oCustomForm As new CustomForm = rawdata
`
Thanks....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过 Json.NET 库?我用它来序列化/反序列化对象到 JSON,并且工作得很好。
它比内置的 .NET 序列化要好得多,因为它不保存与程序集相关的数据(这会使反序列化成为一个真正的麻烦)。
华泰
Have you tried the Json.NET library? I'm using it for serializing/deserializing objects to/from JSON and works perfectly.
It's much better than the built-in .NET serialization because it doesn't save the assembly-related data (which can make a deserialization a real trouble).
HTH
如何:序列化和反序列化 JSON 数据
How to: Serialize and Deserialize JSON Data