Class/structure To Serialize JSON?

Mar 9, 2011

I am trying to figure out a class/struture to handle the following JSON format:

{
"ReturnData": [
{
"id": "msg2DoesNotExistName",

[Code]......

I may or may not have Data for ReturnData and SetValue (one or both at a minimum). I am trying to let the serializer handle most of the formatting without having to check for empty sections and single-item arrays.

View 1 Replies


ADVERTISEMENT

Class Definition To Return Nested JSON Structure Without WCF?

Dec 10, 2011

I'm trying to return code like this (can be found here):

{"hotspots": [{
"id": "test_1",
"anchor": { "geolocation": { "lat": 52.3729, "lon": 4.93 } },

[code].....

View 2 Replies

Asp.net Mvc - How To Serialize Json .NET?

Apr 26, 2012

I am trying to call a rest service..that service returns json object...I am able to send the request but unable to serialize the json...here is the code i am trying

[Code]...

View 1 Replies

Asp.net - Serialize Array To Json?

Jun 23, 2011

I have the following code which serialize an array to json:

Dim col1 As New ArrayList
Dim col2 As New ArrayList
objJSONStringBuilder = New StringBuilder()
objSQLConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("connString"))
objSQLCommand = New SqlCommand("select col1, col2 from table1", objSQLConnection)
objSQLCommand.Connection.Open()

[Code]...

View 2 Replies

VS 2008 Serialize A Class That Implements An Event That Don't Want To Serialize?

Aug 17, 2010

If a class is serialized and has events fired from it that are handled on a form you get the error "Form1 cannot be serialized" in c# you can use (to work around this):

[Code]....

View 1 Replies

JavaScript Serialize Array To JSON?

Mar 28, 2011

I have "Form Designer" web application, in which I need to post the controls of the new form to an ASP.Net page to insert to DB, each time I create form control. I push it into two dimensional array, when user click save, this array will be serialized and sent to Server Page using Ajax.

Array string After Serialization Looks Like :
[
[

[code].....

View 2 Replies

Serialize List In Program To JSON?

Jun 3, 2012

I have the following code to convert a list of messages into json [code]..

View 1 Replies

VS 2010 De-serialize A JSON String?

Apr 22, 2012

I have to de-serialize a JSON string, I am no expert so I give you one example:

JSON String:
{
"myStuff": [
{

[Code]....

View 11 Replies

Serialize A Structure To XML?

Feb 27, 2010

I'm writing a test application in order to figure out how to serialize a structure to XML. I can not get the following code to work for me and it's not obvious to me.

The following defines the structures I am attempting to serialize. I think I have the xml decoration correct - but the errors I'm receiving (see below) don't really give me much information.

Imports System.IO
Imports System.Xml.Serialization
Public Module modTestSerialization

[Code]....

View 2 Replies

Serialize And Deserialize A Structure?

Aug 3, 2009

Is it possible to serialize and deserialize a structure?

I think it isn't because the code I use will not work for a structure but it does work for other data types like an array, string etc

View 3 Replies

Serialize Structure Duplicate The Size?

Sep 28, 2011

I am using simple Serialize Structure to save files with some information in one file like this:

<Serializable()> Structure MyFileSystemStructure
Public FilesNames() As String
Public FilesBytes()() As Byte

[Code].....

The problem that is the result file size when saving structure of image 200KB, will be 400KB

All generated bytes after number 200 are clean (zero value).

View 16 Replies

VS 2008 - Serialize Array Of Structure To XML

Jun 3, 2010

I desperately seek for a code sample to serialize an array of structure elements to a XML. To serialize a simple object of a structure I used:
Private Sub saveEntries()
Dim FS As New FileStream(path, FileMode.Create)
Dim XS As New XmlSerializer(GetType(personEntry))
XS.Serialize(FS, entries(0)) 'serialize first entry of an array - success
FS.Close()
End Sub

Structure looks like this:
<Serializable()> Public Structure personEntry
Dim name As String
Dim d, m, y As Integer
End Structure
Private path As String = "data_file.xml"
Public entries(2) As personEntry
But how to apply this to an array?

View 5 Replies

Serialize A Data Structure And Pass It To Another Report Via Parameter?

Jan 15, 2010

I'm trying to serialize a data structure and pass it to another report via parameter, and this line of code:

Dim s As New System.Xml.Serialization.XmlSerializer(GetType(System.Collections.HashTable))

Produces this error:

An error occurred during local report processing. The definition of the report '/myReport' is invalid. There is an error on line 22 of custom code: [BC30002] Type 'System.Xml.Serialization.XmlSerializer' is not defined.

How can I get around this? I have been able to use fully defined .NET classes in other lines of code, including the following:

Dim outStream As New System.IO.StringWriter()

and

Private colorMapping As New System.Collections.Hashtable()

View 1 Replies

Json - Use An Extension Method With A Structure In .NET?

Aug 21, 2010

I am wondering whether I can use DataContractJsonSerializer to serialize a Structure type, or does it have to be a reference/Class type? I have the following code:

<Extension()> Public Function ToJSON(ByVal target As Object) As String
Dim serializer = New System.Runtime.Serialization.Json.DataContractJsonSerializer(target.GetType)
Using ms As MemoryStream = New MemoryStream()
serializer.WriteObject(ms, target)
ms.Flush()

[Code]...

And yet if I call it on a Structure type, such as a KeyValuePair(Of T1, T2), I get the following error:

Public member 'ToJSON' on type 'KeyValuePair(Of String,Object)' not found.

View 1 Replies

Make A MVC 2 Json Serializable Structure With Apropriate PK Array Keys?

Jan 1, 2010

I have a table with a Int PK column and a name. I want to load them into an object of some sort and return them using Json() ActionResult in MVC 2. I am having a hard time finding a built-in structure that is supported for serialization that keeps a simple key/value structure in tact.

Ultimately I would like to do something like:
Function JsonList() As ActionResult
Dim Things = New Dictionary(Of Integer, String)

[code].....

View 1 Replies

Class Structure - Large Structure That Has Lots Of Properties ?

Jan 5, 2010

I'm new to VB 2008 after having spent a long time with VB6, so I apologize if this is a stupid question. But I'd really like to have this straightened out.

Let's say I have a pretty large structure that has lots of properties.

Code:

Now say that I want an internal database with about 10 instances of this structure total, describing, say, 10 different products that a store sells. When these values are loaded from a database, they remain totally static. (However, they can be different each time a program loads)

Now say that I have a class. Each instance of this class is a type of that BaseProduct structure. Meaning, each instance of the class pertains to one of the 10 types of products that the store sells. However, this class has additional properties that pertain specifically to each instance, which are not static.

Code:

Now, the problem here is... If I have 200 different transactions, each one contains an instance of BaseProduct. BaseProduct is HUGE, and is largely redundant (only 10 types possible), so I think it's a little silly to include a whole copy of it with EVERY transaction. However, the Transaction class really needs information regarding the base product it pertains to. Is there a way to, instead of declaring a New BaseProduct in the Transaction class, to simply make one of the properties of the Transaction class a pointer to a BaseProduct variable?

In VB6, I would accomplish this by making a BaseProduct(10) array, and then giving each Transaction an ID number referring to an entry in that array. But in VB 2008, using class structure, this is impossible. I can't define the BaseProduct(10) array outside of a class in a namespace, and if I define it in the actual application's form, then the class loses modularity since it relies on the application that's using it.

View 11 Replies

VS 2008 Convert The XML Structure Into A Class Structure?

Apr 25, 2010

I'm having a problem that's driving me crazy; I can't understand how to convert the XML structure into a class structure (that I want to use to hydrate a XML document).

The XML document looks like this:

xml
<?xml version="1.0" encoding="utf-8"?>
<artists xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.spotify.com/ns/music/1">

[code]....

View 2 Replies

Serialize A Class That Is Not A Custom Of Our Own?

Apr 14, 2010

I need to look at the properties of an object and I cannot instantiate this object in the proper state on my dev machine. I need my client to run some code on her machine, serialize the object in question to disk and then I can analyze the file.[code]...

View 2 Replies

Serialize And Compress A Class?

Jun 10, 2010

what is the fastest way to serialize and compress a class?

what are the consideration to be made when a long list of objects(classes) have to be serialized and compressed one after the other?

View 4 Replies

Using The .NET Serializer To Serialize XML To A .NET Class?

Nov 9, 2010

I have an XML file:

<?xml version="1.0" encoding="UTF-8"?>
<MyProducts>
<Product Name="P1" />

[code].....

View 6 Replies

VS 2008 Trying To Serialize A Class?

Apr 25, 2009

I'm trying to serialize this class:

<System.Serializable()> Public Class Person
Private _FirstName As String
Public Property FirstName() As String

[code]....

View 2 Replies

C# - Serialize An Instance Of The CustomLineCap Class?

Feb 7, 2012

CustomLineCap does not have the SerializableAttribute applied to it. I want to add a property of this type to an object graph that is currently being serialized/deserialized with a BinaryFormatter. I tried switching to XML serialization but it has a bunch of extra requirements and I don't want to fool with that esp. since it's not my code; it's some open source I downloaded. If there's a way to get BinaryFormatter to ignore the property, that might work. I'd rather subclass it; I just don't know if that will work either.

View 1 Replies

Serialize A Class Containing A Public Event?

May 14, 2012

how can i serialize a class containing a public event + withevents child classes each containing a public event?

View 3 Replies

Serialize A Class That Contains A Generic List?

Oct 7, 2010

I am trying to serialize a class that contains a generic list, and I am finding it all works with the exception of the generic list property. That is to say the other properties are serialized fine and no error is produced.

I have in the past serialized an arraylist - but I thought it was possible to do a generic list in the same way.

Am I missing something or is it not possible to serialize/deserialize a generic list - I have read mixed comments on this..

The relevant parts of the class that gets serialized is defined as..

<XmlInclude(GetType(cConfigUser)), _
Serializable(), XmlRoot(ElementName:="Config")> _
Public Class cConfig

[Code].....

View 3 Replies

Serialize A Class With A Dictionary To A XML File?

Jul 20, 2011

I want to Serialize and Deserialize a configuration class containing a Dictionary to a XML file.Here is an exemple of what the class look like.

Imports
Public
Class

[code]....

When I try to serialize it with a XmlSerializer I get an exception saying to me that it is impossible to serialise Configuration.Parametres because it implements IDictionary.

DateTime
)
Configuration
System.Collections.Generic

View 2 Replies

Serialize A Part Of A Bigger Class?

Aug 24, 2009

I have a issue in a serialization process. I'm trying to Serialize a part of a bigger class.

I've a Class named MyBigClass with contain many property and method, and some of them may not be Serializable.

And I'm trying to Serialize one property of the MyBigClass class, witch is a SortedList named SubClassXList defined as SortedList(Int32, ClassX)

My problem is when it is time to serialize the SortedList (SubClassXList) a error tell me that a Class (say Class B) could not be Serialized because it is not marked as "Serializable", but the Class B in question have nothing to do with the SubClassXList in question.

The only thing I could see, is that the Serialization method try to also Serialize the Main Class (MyBigClass).

Here is the method that I use to Clone a Object ClassX do have the attribute "Serializable()"

Public Function CloneObject(ByVal pObjectToSerialize As Object) As Object
' Create a memory stream and a formatter.
Dim ms As New IO.MemoryStream()

[Code].....

View 5 Replies

C# - Proxy Pattern - Serialize A Class Into A String

May 10, 2011

I need to be able to serialize a class into a string, and I know of 2 patterns:

1) (normal) Serialization pattern

2) Proxy Serialization pattern

I've read [URL] (the only website in google that talks about the proxy-serialization pattern) and still cant find the advantage or benefit of using this pattern. Could someone explain what exactly is the proxy serialization pattern, or rather exactly what problem does the proxy-serialization pattern solves that the normal-serialization pattern doesn't solve?

View 1 Replies

Winforms - Serialize The Main Class In My VB Solution?

Apr 5, 2011

I'm trying to serialize the main class in my VB solution. I've added the Serializable attribute at the top of my class like so:

[code]...

I'm guessing this is because you can't serialize the form that is attached to the class or something, but I really don't know what I'm doing. Can I serialize all of the objects contained in my Form1 class somehow, without getting this error? I don't want to store any data about the form controls, I just need to save all the objects that I've defined at the top of the Form1 class.

View 1 Replies

.net - Can't Call Serialize() On Instance Of Serializable Singleton Class?

Nov 28, 2011

I have a VB.NET singleton class which implements Serializable:

Imports System.IO
Imports System.Runtime.Serialization

<Serializable()> Public Class CoordinateHistory[code].....

My problem is that I can't actually call .Serialize() on the instance of this class, like all of the examples online show. What am I doing wrong?

View 2 Replies

C# - Serialize A Class Containing An Object (of Any Serializable Type) To XML (Conditon: .NET 1.1)?

Sep 21, 2011

Question: I must get the content of all sessions in a HttpModule, under .NET 1.1. (don't ask my why certain people still use it) I can write the module, I can get the sessions. But... sessions are stored as

[Code]...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved