Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

(Trying to use) DataContractJsonSerializer

$
0
0

I am trying to follow this example: http://msdn.microsoft.com/en-us/library/bb412179(v=vs.110).aspx

But I am just doing a simple desktop app; no WCF, no AJAX, no web anything.

My code is in VB.Net and I am getting a syntax error which I do not understand on this statement:

dim ser As New datacontractjsonserializer(typeof(JsonRow))

The help want me to add "Is" so that it would end like this ...(typeof(JsonRow)Is).  But that makes no sense to me and did not help.

I don't have much code yet.  Here it is:

Option Strict On Option Explicit On Option Infer Off Imports System.Runtime.Serialization.Json Imports System.Web.Script.Serialization 'needs reference for System.Web.Extensions (which is not in the Client profile) Imports System.IO Public Class Form1

dim ser As New datacontractjsonserializer(typeof(JsonRow))

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim jr As New JsonRow Dim stream1 As New MemoryStream(System.Text.Encoding.ASCII.GetBytes("{""somenums"": ""1"",""someDate"": ""1.1.2014"",""viewdata"": ""1119958""," & _"""visitdata"": ""152452"",""uniquedata"": ""125873""}".ToCharArray)) stream1.Position = 0 Dim sr As New StreamReader(stream1) jr = DirectCast( End Sub End Class <Serializable()> _ Public Class JsonRow Public somenums As String Public someDate As String Public viewdata As String Public visitdata As String Public uniquedata As String Sub New() 'we need a parameter-less constructor to make it serializable End Sub End Class


I'd appreciate it if anyone can help me with this.

Thanks,  Bob



Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>