serialization

DeSerializing Memory Stream with Speical Characters not working vb.net

Dim myString As String 'This string is XML with special characters like 'Ö' Dim memstream As New IO.MemoryStream(System.Text.UTF8Encoding.Default.GetBytes(myString)) Dim serializer As New XmlSerializer(GetType(ABCD)) Dim abc As ABCD = CType(serializer.Deserialize(memstream), ABCD) This is throwing an exception 'bad xml' due to specia...

Serialize And Deserialize Object Graph To and From String Key/Value Pair

Assuming the following model public class MyObject { public string Name { get; set; } public ICollection<MyObjectItem> Items { get; set; } } public class MyObjectItem { public string Name { get; set; } public int Total { get; set; } } I want to serialize and deserialize this object graph to a list of key/value pair o...

Why do I need to use .d to access data returned by jQuery AJAX?

I've put together some jQuery AJAX code using some tutorials I found on the internet. I'm new to jQuery and want to learn how to do things betters. I have a coworker who put together a beautiful web application using a lot of jQuery. The thing I'm most confused about here is: why is it necessary to use the ".d" when referring to the r...

Does there exist any serialization library for c++ that is as easy as Google Gson/XStream for java?

It seems like every library I've ever seen recommended doesn't offer an api as easy as this. MyClass* instance = (MyClass*)SerializationUtility.serialize(someString); Has anyone heard of something this easy for c++? In hava there are a couple of libraries that are so easy to use for converting text into objects and objects into text. ...

Boost Serialize - Serialize data in a custom way

If I'm using Boost Serialization to serialize an Integer: #include <boost/archive/text_oarchive.hpp> #include <iostream> int main() { boost::archive::text_oarchive oa(std::cout); int i = 1; oa << i; } The result will be the following: 22 serialization::archive 5 1 Now I'm curious if and how I could change the way, certa...

Trying to pass an array outside the scope into a function for echo'ing.

Hello my fellow programmers, I have a problem (other than not knowing enough) I need to know how to pass an array from outside the scope to then back inside, in a function which then echo's a specific array index. I have trowlled through the net trying to find solutions, asked fellow programmers for help but nothing thus far has worked...

Is it safe to use bytecode enhancement techniques on classes that might be serialized and why?

I haven't tried this yet, but it seems risky. The case I'm thinking of is instrumenting simple VO classes with JiBX. These VOs are going to be serialized over AMF and possibly other schemes. Can anyone confirm or deny my suspicions that doing behind-the-back stuff like bytecode enhancement might mess something up in general, and provi...

Serializing C-style structs (using C++)

Is it evil to serialize struct objects using memcpy? In one of my projects I am doing the following: I memcpy a struct object, base64 encode it, and write it to file. I do the inverse when parsing the data. It seems to work OK, but in certain situations (for example when using the WINDOWPLACEMENT for the HWND of Windows Media Player) i...

XML Serialization : Has property of type Class1 : Class1 has another property : How to write the property of Class1 into XML?

I want to serialize a class. In this class there's a property, type of Class1, while there are other properties in Class1. public abstract class ComponentBase { [ToSerialize]//An attribute defined my me, indicating whether or not to serialize this property. public ComponentArgs Parameters { get; set; } } public class ComponentArgs { ...

Creating XML and XSD files based on .NET entities

Hi I've been looking around for this for quite some time and cannot seem to get anywhere. I need to find a way to accomplisht the following two tasks, based on a .Net Entity object: Create an XML file that contains the data in this entities, complete, with cascading nodes (representing foreign key relationships, basically). I've consi...

Parsing JSON to Java POJO's using GSON

I have a very straight forward issue here. I need to take JSON coming from the API and convert it to objects I created for them. This far, it will deserialize them into my List but each Metric object has null values JSON COMING IN { "metrics": [ { "metric": { "type": 1, "name": "slide-11-start", ...

Deserialization throws IllegalAccessException

I'm trying to deserialize an object but it doesn't work. Has anyone an idea how to handle it? public static List<Leistung> findAll(Context ctx) { List<Leistung> result = null; FileInputStream in = null; Object obj = null; File f = ctx.getFileStreamPath("file.obj"); if (f.exists()) { try { in = c...

Serializing an object for two different uses in two different formats (should be simple..)

I have an object which is marked as [Serializable] and it's properties are marked with [XmlAttribute] and [XmlIgnore].It's serialized for our web-site use, and it works well. Now I need to serialize the same object for a different use (web service), in json format. I know I can easily serialize objects with the [DataContract] and [Dat...

How to avoid persistence logic in domain model?

My domain model looks like this: class Group { private List<Person> persons; public void AddPerson(Person p) { persons.Add(p); DoSideEffect() } public List<Person> GetPersons() {...} } Now I need to persist it. By DDD I cannot add any persistence attributes to this class so xml serializers will not work...

Deserialize custom SOAP/XML to objects

Hello, i have this xml/soap from a sharepoint webservice call: <GetAllUserCollectionFromWeb xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/"&gt; <Users> <User ID="ID" Sid="ID" Name="XXX" LoginName="XXX" Email="XXX" Notes="" IsSiteAdmin="False" IsDomainGroup="False" Flags="0" /> <User ID="ID" Sid="ID" Name="XXX" ...

How to serialize to c# code?

I am testing a web-service that gets an object as a parameter. To create this object I go through an online store that we are maintaining and the end result is a rather big object, we can call it BO, sent to a web-service. Now we seem to have a bug that comes up when BO is in a specific state. I tediously go through the online store t...

To initialize a transient field, what is the most simple solution

class MyClass implements Serializable { transient int myTransient; //Other variables } When I restore this class I want to initialize myTransient manually, but otherwise I just want to use the default serialization. How can I inject an init() method into the object restore process without re-writing the entire serialization mechan...

XML Serialization of an Interface

Hi All, I have a problem that I'm working in nHibernate project that have the following object: [Serializable] public class Prototype { public virtual long Id { get; private set; } public virtual string Name { get; set; } public virtual IList<AttributeGroup> AttributeGroups { get; private set; } } and I have created a ...

XML Deserialization performance in ASP.NET MVC

I have a MVC 2 web application that will have a high volume of users. One page in particular will be rendered based on XML from a database table. I was hoping to use de-serialization to parse the XML into an object tree for easier access to the data. However I'm not so sure that this will perform well enough for my users. Is there any ot...

Spring: serializing objects with references to non-serializable beans

The class below (my implementation of UserDetailsService) gets tied to the session and the session gets serialized (in google apps engine). I watched a Spring 3 presentation recently that said that beans, such as userDao, shown below, are loaded by a proxy which doesn't serialize the bean, but stores only the name and re-obtains the re...