serialization

Serialize or save PolylineOptions in Android

半腔热情 提交于 2019-12-23 02:39:28
问题 In my Android app I am already saving some strings to the SharedPreferences and serializing an ArrayList with Strings so this data is saved and can be used for future purposes. Even when the app is closed. A minute ago I discovered that I need to save my PolylineOptions for future use as well. PolylineOptions contain some coordinates to draw a line on my map with a color and width. I discovered that PolylineOptions aren't serializeable like Strings. Is there a way to 'save' my PolylineOptions

How to return data from nested serializers inside serializers built on the fly?

梦想的初衷 提交于 2019-12-23 02:37:37
问题 Recently I have been trying out new things with Django, to try and simplify writing responses in the views, might not be worth doing in the end, but I'm still interested to see if it can be done. So typically, we would have the following serializer for returning back information; # serializers.py class SomeDefinedSerializer(serializers.ModelSerializer): extra_model = SomeExtraModelSerializer() greet_name = serializers.SerializerMethodField() class Meta: model = SomeDefinedModel fields = (

Django Rest Framework Recursive Nested Parent Serialization

强颜欢笑 提交于 2019-12-23 02:34:18
问题 I have a model with a self referential field called parent. Model: class Zone(BaseModel): name = models.CharField(max_length=200) parent = models.ForeignKey('self', models.CASCADE, blank=True, null=True, related_name='children') def __unicode__(self): return self.name Serializer: class ZoneSerializer(ModelSerializer): parent = PrimaryKeyRelatedField(many=False, queryset=Zone.objects.all()) parent_disp = StringRelatedField(many=False, source="parent") class Meta: model = Zone fields = ('id',

Serializing Object With Invalid Enum Value

久未见 提交于 2019-12-23 02:31:40
问题 I have a Windows Phone 7 project that connects to a .NET web service to fetch data on demand. Both the WP7 project and the web service use a copy of the same c# class library. Part of this library is an enum of EmployeeType : Public enum EmployeeType { Standard = 0, TeamLeader = 105 } Since the app was released, the web service class library has had a change made to it - adding a new enum value. ( SeniorManager = 110 ) Therefore, when I receive an object on the phone with a property

Changing JMS serialization JSON label names, according to api level

自闭症网瘾萝莉.ら 提交于 2019-12-23 01:52:06
问题 I'm using jms/serializer-bundle with Symfony, and a serialization configuration in YML form, to serialize some Doctrine objects as JSON. An existing API means that some of the labels were named with underscores (e.g. "created_on") createdOn: expose: true groups: label serialized_name: created_on ... "created_on": "2014-03-06T14:28:17+0000", but I'd like to tidy this up for a new API version and return responses in camelCase for new API calls. I had hoped/thought that I could use the JMS

Service - client interface, architecture advice

拜拜、爱过 提交于 2019-12-23 01:28:10
问题 I have a Windows WCF serivce and Web client. My service has one method [OperationContract] SubmitOrder(OrderInfo info).... // class used to pass all relevant data [DataContract] class OrderInfo { [DataMember] OrderType Type; // general order data } It was great until I have introduced new order types (controlled by OrderInfo.Type property). You can think of new order type as derived from general order (in terms of behaviour). Each new order has some additional properties. What is the best

Service - client interface, architecture advice

若如初见. 提交于 2019-12-23 01:28:05
问题 I have a Windows WCF serivce and Web client. My service has one method [OperationContract] SubmitOrder(OrderInfo info).... // class used to pass all relevant data [DataContract] class OrderInfo { [DataMember] OrderType Type; // general order data } It was great until I have introduced new order types (controlled by OrderInfo.Type property). You can think of new order type as derived from general order (in terms of behaviour). Each new order has some additional properties. What is the best

JSON.NET customizing the serialization to exclude a property name

自闭症网瘾萝莉.ら 提交于 2019-12-23 01:19:51
问题 I am using Json.NET and I have the following code. public class Row { [JsonProperty] public IDictionary<string, object> Cells { get; set; } } The rows and cells are dynamically generated and I had C# dynamic/Expando feature to create those Cells. When Json.NET serializes the dynamic instances, it produces the correct json structure I want. However for a large data structure it has an adverse effect on the performance. For example, JsonSerializer calls DynamicObject TryGetMember quite

Is there a reason to use a real serialVersionUID?

我的梦境 提交于 2019-12-22 19:43:25
问题 This question is an exact duplicate of: Why generate long serialVersionUID instead of a simple 1L? Ironically, answered by Michael Bogswardt as well. Michael Bogswardt's answer to generating a serialVersionUID got me thinking. Is there any reason to generate a proper serialVersionUID like eclipse and IDEA (or just plain serialver)? Or is plugging in a 1L just as good? 回答1: The only use of a "real" serialVersionUID is for backword compatibility. If it is a new class, use whatever numbering

How to serialize ArrayList of objects?

别等时光非礼了梦想. 提交于 2019-12-22 19:42:48
问题 I want to serialize an arraylist of Item but it doesn't work.... my Item class extends Stuff class and has some subclasses . all of my classes implement Serilalizable. i have this part : try{ // Serialize data object to a file ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("MyData.ser")); out.writeObject(myData); out.close(); // Serialize data object to a byte array ByteArrayOutputStream bos = new ByteArrayOutputStream() ; out = new ObjectOutputStream(bos) ; out