Questions tagged [serialization]

15182 questions
1

votes
1

answer
59

Views

How do you call an object which state can be completely described by its string representation?

Is there a name in the OOP world to refer to such objects? For example, in java 'Word'.toString(); Will return an output of Word. This is a string representation of the entity that exists currently in the program. Some more examples can be accomplished with other datatypes like Doubles, Integers, m...
Luis Durazo
1

votes
2

answer
523

Views

Azure CloudBlobStream serialization (with Json.NET)

I have a little problem. My environment is a console app in .NET Core 2.1. Look at the this code: private static void Main(string[] args) { try { Console.WriteLine($'Test starts: {DateTime.Now.ToString('o')}'); string connectionString = '[My connection string]'; string containerName = 'mycontainer';...
Attilio Gelosa
1

votes
3

answer
50

Views

How to work around Gson serialization giving different results when using generic wildcards?

Consider this example: static class BaseBean { String baseField = 'base'; } static class ChildBean extends BaseBean { String childField = 'child'; } static class BaseBeanHolder { List
GhostCat
1

votes
1

answer
21

Views

How do I append MYSQL JSON

I have the following in my database when I run SELECT type FROM office; +--------------------------------------------------------+ | type | +--------------------------------------------------------+ | a:2:{i:0;s:16:'Shared Workspace';i:1;s:9:'Worksho...
John Crawford
1

votes
1

answer
2.5k

Views

Boost::Serialization Mpi Sending array of user defined types

I want to send my Array class using boost Mpi template class Array { private: int size; T* data; public: // constructors + other stuff }; Here T can be any built in type or user defined type. Suppose I have a class complex struct complex { std::vector real_imag; // contain two elements }; So the que...
Noman Javed
1

votes
3

answer
1.3k

Views

serialize to XML path issue

I am trying to serialize my Report class info to an XML. At this point I think all of the serialize and deserialize code works, but for the initial write, I'm having trouble performing the serialize, because the XML file doesn't exist yet. for an empty text file, i can use: StreamWriter sw = File.C...
ikathegreat
1

votes
1

answer
745

Views

Reference existing data when deserializing Java objects?

My object graph consists of Hibernate entities. Now most of the objects don't exist in the new database. However some do. So my object is like this: Class MyObject{ Set bset; Set cset; } The items in bset need to be instantiated and persisted after deserialization. However, the items in cset alrea...
Osman
1

votes
4

answer
13.5k

Views

Generate XML file in C# with XSD file

I am trying to build a new XML file with C# using an existing XSD file. this is the xsd file : Format: yyyyMMdd Format: yyyyMMdd The feedback type for this file I have done the following things to create the XML file : made a class with xsd.exe I added the class to my project wrote the following f...
Vandoorn Kevin
1

votes
1

answer
1.6k

Views

linker errors with boost::archive and serialization

I am new to VC++ 12.0 with MFC and also the boost library. However, I need to use the boost library to serialize the vector storing customized data types. I read the examples of DEMO_GPS and used similar codes in my problem. Unfortunately, I came across the following linker errors: 1>SMTDoc.obj : e...
Vincent8Hz
1

votes
1

answer
997

Views

Symfony Serializer of DateTime Response String

When attempting to perform a doctrine query and serialze it to json (not using JSM, using the symfony serializer) I get the following in the json: ''due':{'timezone':{'name':'Europe/Berlin','transitions':[{'ts':-2147483648,'time':'1901-12-13T20:45:52+0000','offset':3208,'isdst':false,'abbr':'LMT'},{...
Lee
1

votes
1

answer
46

Views

How to make Perl's XML::Libxml serializer to use utf-8 encoding?

I'd like to serialize an xml with XML::LibXML, but it always converts utf-8 characters to html representations: I get á from 'á', etc... How can I make it use utf-8 instead? use strict; use XML::LibXML; use utf8; my $str = 'árvíztűrő tükörfúrógép'; my $dom = XML::LibXML->load_xml(string =...
lmocsi
1

votes
3

answer
47

Views

Why do you extend Serializable in Scala?

I'm going through some Sapark projects in Scala, and I see that all of the objects are extending Serializable . It's like : object someName extends Serializable { //some code } I understand that serialization is often used for storing or communicating data structures, so that the data can be easily...
div93
1

votes
2

answer
84

Views

How do I specify that a list property's contents are xml serialized, but the property itself should not be respresented in the markup?

I've got a class like this: [XmlRoot('channel')] public class Channel { [XmlElement('title')] public String Title { get; set; } [WhatElseGoesHere] [XmlArrayItem('item')] public List Items { get; set; } } My desired output is this: The title {item content} {item content}
Daniel Schaffer
1

votes
0

answer
90

Views

Standard serialization protocol to serialize set of objects to disk

I am looking for standard protocol that provides ability to serialize set of object (same type) to a file, but also provide easy way to align to object boundary if reader/de-serializer start reading from random byte offset. After googling I found out that Apache Avro provides this functionality usi...
user2774767
1

votes
1

answer
303

Views

Serializing custom classes with custom Settings Provider

I'm trying to save the following classes using a custom Settings Provider but keep getting a null reference error (error details below). [Serializable] public class SoundClips { [System.Xml.Serialization.XmlElementAttribute('Items')] public List Items { get; set; } public SoundClips() { Items = new...
Daniel
1

votes
1

answer
357

Views

Rails 5 - How to get serializable_hash for activerecord?

In rails 5, I am trying to get a data in serializable_hash format. First set of data format is in correct but second set of data is in different format. The Comment module works like parent and children format, one comment has_many comments by adding parent_comment_id. For parent comment, now data...
Shruthi R
1

votes
0

answer
249

Views

Big CSV to pickled dict

I have a 1 GB CSV file like this (16-char-max-string;int) hello;1798732 you;1762 ... that is slow to be parsed into a dict, that's why I would like to do it once, save it as pickled file (or any other serialization method), and then reopen this already-processed file for further use. I tried:...
Basj
1

votes
0

answer
338

Views

Serialize enum to string with RestSharpJsonNetSerializer [duplicate]

This question already has an answer here: Why serializing Version with JsonPropertyAttribute doesn't work? 1 answer parsing an enumeration in JSON.net 1 answer How to tell Json.Net globally to apply the StringEnumConverter to all enums 5 answers I have my RestSharpJsonNetSerializer class below. I...
Razkar
1

votes
1

answer
82

Views

Springboot Jackson Generic data type serialize

I have a class public class ResponseWrapper { private T mObject; /** * @return the mObject */ public T getmObject() { return mObject; } /** * @param mObject the mObject to set */ public void setData(T mObject) { this.mObject = mObject; } } T is a generic type object which I set. So i'll initialize...
Uday
1

votes
1

answer
49

Views

Getting UTF-8 polish characters after serialization data using Jquery

I wrote script that are sending data from HTML form to server using ajax request. $.ajax({ type: $(this).attr('method'), cache: false, url: $(this).attr('action'), data: $(this).serialize(), dataType: 'json' }); I input data into my HTML form with: name = 'ładna pogoda' My $_POST data in PHP script...
L. Z.
1

votes
1

answer
139

Views

Serializable Isolation Level

If serializable isolation level is valid, what is the content of table X ? Because of serializability, I think that transaction B cannot perform any operation. Thus, row b is not placed in the table X, and delete row b operation of transaction A is not performed. As a result, table X only includes r...
Goktug
1

votes
0

answer
47

Views

C# JSON Deserialize Dictionary<string, Dictionary<string, string>>

JSON Data: { 'MetaData ': { 'Id': '1', 'CreatedBy': 'Ravi', 'CreatedOn': '06/01/2018', 'State': 'Completed', 'Level': 'Curator' }, 'tbDm': { 'textBox1': 'Ravi', 'textBox2': 'Chaitag', 'textBox3': 'Jp', 'textBox4': 'Ch' }, 'tbCO': { 'textBox5': 'Cha', 'textBox7': 'C', 'textBox8': 'ra', 'textBox6': 'j...
Ravi
1

votes
1

answer
377

Views

Django Rest Framework - automatically annotate queryset

I use one Serializer in many different places in my project. I need to use one annotation but the problem is that I don't want to annotate it in all views so I would like to do universal annotation in the Serializer itself. It is possible? Now I need to do this before every serialization: City.objec...
Milano
1

votes
2

answer
321

Views

How to map to request.post json key to model serialializer field in django?

I am newbie in djnago-rest-framework. I am leaning about creating instance with serializer in DRF. Let suppose I have models who look like this (models.py) : from django.db import models class Reporter(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_lengt...
Amit
1

votes
2

answer
369

Views

DRF testing Model Serializer - Django Restframework

I am testing my Serializer model in django restframework with APITestCase. this is my structure : class Usertest(APITestCase): def test_userprofile_create(self): user = User.objects.create(username='asghar', password='4411652A', email='[email protected]',) profile = UserProfile.objects.create(fullname=...
taghiss
1

votes
1

answer
94

Views

How to serialize my own generic List?

I wrote a generic List type. How do I make the List serializable? My main concern is with the GetObjectData() method. The following is my List class with its methods. I have done XML serialization before with the List that is already available in C# but I just don't know what I should write in th...
Blopsrusher
1

votes
0

answer
78

Views

How does Flink handle final fields in a POJO during deserialization?

In my Flink graph, I have certain POJO classes with final fields. These fields are set in an overloaded constructor. Example, I have a Car POJO with final fields, and a HybridCar class that derives from Car as shown below. public class Car { private final int year; private final int modelNumber; p...
victtim
1

votes
1

answer
163

Views

Spark can not serialize the BufferedImage class

I have a Not Serializable Class exception in Spark 2.2.0. The following procedure is what I am trying to do in Scala: To read from HDFS a set of JPEG images. To build an array of java.awt.image.BufferedImageS. To extract the java.awt.image.BufferedImage buffer and store it in a 2D array for each ima...
Vitrion
1

votes
2

answer
185

Views

How to print a Java List to a Yaml List in brace ([ ]) format, using Jackson yaml

I am trying to find a way to print Java ArrayLists to Yaml lists, in the following format: [list-element1,list-element2,list-element3...] However,I have only managed to print them into Yaml lists in the alternative format: -list-element1 -list-element2 -list-element3 Is there a way that the first ca...
atsag
1

votes
0

answer
359

Views

C# MongoDb deserialization of an abstract sub-document

Prefix: Using .net 4.6.1, C# 7, C# MongoDb 2.5.0 Issue in general: I have a small class which contains a field of an abstract type. [BsonIgnoreExtraElements(true)] public sealed class FatherAlmighty { [BsonId] public ObjectId Id; public MyAbstract Item; } also, this MyAbstract is obviously an abstra...
Ori Refael
1

votes
1

answer
145

Views

How to serialize proto3 message as an array

I use protoc to generate java classes used to serialize data. Sometimes, for example, I want my json to look like: [ { 'foo': 1, 'bar': 'a' }, { 'foo': 2, 'bar': 'b' }, { 'foo': 3, 'bar': 'c' } ] I will define an protobuff message: message Sample { uint64 foo = 1; string bar = 2; } And I have to def...
Dasshield
1

votes
0

answer
426

Views

Cannot parse Json to data class using kotlinx.serialization

In an Android project, I am trying to parse a Json response from a remote endpoint using kotlinx.serialization and Retrofit. I am using Jake Warthon's https://github.com/JakeWharton/retrofit2-kotlinx-serialization-converter to set the converter when setting up the retrofit instance Retrofit.Builder(...
Nicolás González
1

votes
0

answer
72

Views

.NET does not deserialize correctly DateTime values in DataSet serialized to XML

I am writing a program that serializes a DataSet into a XML file, then the same program deserializes it in another computer to save it into a database. For serialization/deserialization I use the DataSet ReadXml/WriteXml methods. The problem is that .NET isn´t deserializing DateTime values correctl...
Alejandro
1

votes
3

answer
1.4k

Views

import_meta_graph fails with Data loss: not an sstable (bad magic number)

Context I came across this problem while trying to solve another error. The first error (original problem) was that when I tried to restore a meta graph I would get Cannot find KeyError: 'The name 'multi_rnn_cell_6' refers to an Operation not in the graph.'. In trying to create the MVCE for that pro...
Josh Albert
1

votes
0

answer
299

Views

Symfony 4: Implement links routes with Hateoas-Bundle

I try the install 'willdurand/hateoas-bundle' inside my project with Symfony4 but there is a problem because the 'HATEOAS-BUNDLE' only working with Symfony3 and below. requires symfony/framework-bundle ~2.3 - v3.4.3 In this case I used willdurand/hateoas but I checked and there is not have BazingaHa...
Guido T.
1

votes
0

answer
52

Views

xml string to Object mapping does not happen

I have a stored procedure that sends a response as an xml string So I've create a class and want to map the response of this store procedure to an Object of some type This is my class and it's proprieties. The Populate method is where i want to do my xml to object mapping. [XmlRoot('SiteItem')]...
MCR
1

votes
0

answer
95

Views

Is the schema needed to deserialize protobuf bytestring?

I'm trying to deserialize some Protobuf bytestrings, in Python, outside of GAE(AppEngine) environment. I'm wondering if I need the message schema for this use case. Approaches I've tried so far includes google.cloud.proto.datastore.v1.entity_pb2.Entity.ParseFromString(): >>> pb = ... ## fetched a...
xiaolong
1

votes
0

answer
43

Views

c# - Different XmlArrayItem-Attributes for derived classes

I know that I can specify xml-element-names for list-elements when using XmlSerializer via the XmlArrayItem-attribute. This however only works for lists, which are fields (or properties). Is there a way to set this for any list? Example: [XmlInclude(typeof(Foo1)), XmlInclude(typeof(Foo2))] public a...
Thomas
1

votes
0

answer
90

Views

Robust representation of PathBuf for code generation in Rust

I have a list of pairs of PathBufs and I want to generate code that will give an efficient mapping function - looking up a path and giving me the corresponding path in the pair. To do this I am creating a static hash-map with phf. My current implementation is a pub static PATH: phf::Map. I have an a...
maninalift
1

votes
3

answer
19

Views

persist object-model to JSON

public class Portfolio { public string Name {get; set;} public Dictionary Positions {get; set;} } public class Position { public string Ticker {get; set;} public decimal Size {get; set;} } JsonConvert.SerializeObject(portfolio); will produce for example : { 'Name': 'SP500', 'Positions': { 'AOS': {...
BaltoStar

View additional questions