0

I have seen there are many examples in C# version. Same also as DataContractJsonSerializer class in MSDN. Anyone please help me on VB.net version?

2
  • 1
    Porting C# code to VB.NET is usually straightforward. A converter like this one developerfusion.com/tools/convert/csharp-to-vb does a good job. If you have any specific problem then edit your post with more details. Commented Nov 3, 2009 at 14:03
  • Indeed - or use "reflector", which can do (limited) translation. Commented Nov 3, 2009 at 16:52

2 Answers 2

1

Here's the same source code I have written in another question. It's a very simple piece of code that uses the library JAYROCK (you can download it free of charge here: http://jayrock.berlios.de/) that will read a JSON formatted string and will output the value of a parameter call "message" that is nested inside "error". Very basic stuff, but it might help you...

Dim cMessage As String = "{ ""error"" : { ""code"" : 500, " & _
                                """message"" : ""Error Executing Task. " & _
                                "Error executing tool.""," & _
                                """details"" : [] " & _
                                "}" & _
                                "}"

Dim objResponse As JsonObject


objResponse = CType(JsonConvert.Import(cMessage), JsonObject)

MsgBox( "Last response was: " + objResponse("error")("message") )

P.S.: In order to get this code working don't forget to import Jayrock.Json and Jayrock.Json.Conversion

Sign up to request clarification or add additional context in comments.

Comments

0
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim ser As New DataContractJsonSerializer(GetType(Product))
            Using fs As FileStream = File.OpenRead("c:\jsonText.txt")

                Dim product As Product = TryCast(ser.ReadObject(fs), Product)
                MessageBox.Show("Product Name: " & product.Name)
            End Using
        End Sub
    End Class

    <Serializable()> _
    Public Class Product
        Public Name As String
    End Class
End Namespace

Here is the vb.net sample taken from msdn and converted by developerfusion converter

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.