How can I serialize internal classes using XmlSerializer?

From Sowmy Srinivasan’s Blog – Serializing internal types using XmlSerializer: Being able to serialize internal types is one of the common requests seen by the XmlSerializer team. It is a reasonable request from people shipping libraries. They do not want to make the XmlSerializer types public just for the sake of the serializer. I recently … Read more

Java object Serialization and inheritance

Serializable is just a “marker interface” for a given class. But that class must adhere to certain rules: http://docs.oracle.com/javase/1.5.0/docs/api/java/io/Serializable.html To allow subtypes of non-serializable classes to be serialized, the subtype may assume responsibility for saving and restoring the state of the supertype’s public, protected, and (if accessible) package fields. The subtype may assume this responsibility … Read more

Difference between Microsoft’s Bond and Google’s Protocol Buffers [closed]

In general, Bond has better type system and supports multiple protocols. In particular, pros are: Bond supports generics Bond has different types to represent collections: vector<T>, map<T>, list<T> Bond supports type-safe lazy deserialization (bonded<T>) Bond supports multiple formats (fast binary, compact binary, XML, JSON) + marshaling and transcoding Cons: Bond doesn’t support different types for … Read more

Save HTML locally with Javascript

You can just use the Blob function: function save() { var htmlContent = [“your-content-here”]; var bl = new Blob(htmlContent, {type: “text/html”}); var a = document.createElement(“a”); a.href = URL.createObjectURL(bl); a.download = “your-download-name-here.html”; a.hidden = true; document.body.appendChild(a); a.innerHTML = “something random – nobody will see this, it doesn’t matter what you put here”; a.click(); } and your … Read more

JSON Serializing Django Models with simplejson

I would go with extending simplejson. Basically, you want to plug in django’s serialization when the JSON encoder encounters a QuerySet. You could use something like: from json import dumps, loads, JSONEncoder from django.core.serializers import serialize from django.db.models.query import QuerySet from django.utils.functional import curry class DjangoJSONEncoder(JSONEncoder): def default(self, obj): if isinstance(obj, QuerySet): # `default` must … Read more

Object Serialization to JSON (using Gson). How to set field names in UpperCamelCase?

Taken from the docs: Gson supports some pre-defined field naming policies to convert the standard Java field names (i.e. camel cased names starting with lower case — “sampleFieldNameInJava”) to a Json field name (i.e. sample_field_name_in_java or SampleFieldNameInJava). See the FieldNamingPolicy class for information on the pre-defined naming policies. It also has an annotation based strategy … Read more