如何手动反序列化

时间:2014-01-08 20:38:39

标签: serialization deserialization manual json-deserialization

我有这个字符串

{\"Data\":null,\"ErrorCode\":0,\"IsSuccess\":false,\"Message\":\"No hay informacion para descargar\",\"SuccessCode\":100}

{\"Data\":{\"BranchCodes\":[\"30\"],\"ProcessId\":86},\"ErrorCode\":0,\"IsSuccess\":true,\"Message\":null,\"SuccessCode\":0}

{\"Data\":{\"BranchCodes\":[\"30\",\"97\"],\"ProcessId\":87},\"ErrorCode\":0,\"IsSuccess\":true,\"Message\":null,\"SuccessCode\":0}

我想转换为此对象

Class WorkGroupMetric
    Public Property Data() As Data
        Get
            Return m_Data
        End Get
        Set(ByVal value As Data)
            m_Data = Value
        End Set
    End Property
    Private m_Data As Data

    Public Property ErrorCode() As Integer
        Get
            Return m_ErrorCode
        End Get
        Set(ByVal value As Integer)
            m_ErrorCode = Value
        End Set
    End Property
    Private m_ErrorCode As Integer

    Public Property IsSuccess() As Boolean
        Get
            Return m_IsSuccess
        End Get
        Set(ByVal value As Boolean)
            m_IsSuccess = Value
        End Set
    End Property
    Private m_IsSuccess As Boolean

    Public Property Message() As String
        Get
            Return m_Message
        End Get
        Set(ByVal value As String)
            m_Message = Value
        End Set
    End Property
    Private m_Message As String

    Public Property SuccessCode() As Integer
        Get
            Return m_SuccessCode
        End Get
        Set(ByVal value As Integer)
            m_SuccessCode = Value
        End Set
    End Property
    Private m_SuccessCode As Integer

End Class

Public Class Data
    Public Property BranchCodes() As List(Of String)
        Get
            Return m_BranchCodes
        End Get
        Set(ByVal value As List(Of String))
            m_BranchCodes = value
        End Set
    End Property
    Private m_BranchCodes As List(Of String)
    Public Property ProcessId() As Integer
        Get
            Return m_ProcessId
        End Get
        Set(ByVal value As Integer)
            m_ProcessId = Value
        End Set
    End Property
    Private m_ProcessId As Integer
End Class

我需要帮助我在visual studio 2005中使用scriptask for ssis。 我不能使用JavaScriptSerializer或类似的,这必须手动。

1 个答案:

答案 0 :(得分:0)

你真的想避免手动执行此操作,我会调查json.net,它不是.net框架的一部分,应该与vs2005一起使用。 http://james.newtonking.com/json