serialization

Caching objects with EHCache

拈花ヽ惹草 提交于 2021-02-11 12:55:48
问题 When caching https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/env/Environment.java with EHCache it throws: Caused by: org.ehcache.spi.serialization.UnsupportedTypeException: No serializer found for type 'jetbrains.exodus.env.Environment' at org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider.getSerializerClassFor(DefaultSerializationProvider.java:136) at org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider

Python 3 numpy.load() until End of File

孤人 提交于 2021-02-11 12:27:10
问题 Suppose I'm generating a random number of arrays that I need to serialize def generator(): num = 0 while num < random.randint(0, 10): yield np.array(range(2)) num += 1 with open('out.npy', 'wb') as f: for item in generator(): np.save(f, item) Now how do I know exactly how many times I have to np.load() to get all the arrays back? np.load() will eventually throw an exception so I came up with with open('out.npy', 'rb') as f: try: while 1: item = np.load(f) print(item) except: print("EoF") but

Remove empty JSON objects from an array in Jackson serialization

二次信任 提交于 2021-02-11 07:53:31
问题 I have a List in a Java Pojo class. That list contains some MyChildPojo objects which are not null but can have properties with null values. Example: MyChildPojo obj1 = new MyChildPojo(); MyChildPojo obj2 = new MyChildPojo(); I have added @JsonInclude(JsonInclude.Include.NON_EMPTY) on my MyChildPojo class so null properties will not be added while serializing the object. Now my final serialized output for the List object is: [ {}, {} ] I want to remove the complete List object in this case. I

Serialize list of strings as an attribute

試著忘記壹切 提交于 2021-02-11 06:31:25
问题 I am working with XML serialization, I am doing good so far. However, I stumbled with a problem and I wish if you guys can help me with it. I have a class as following: public class FrameSection { [XmlAttribute] public string Name { get; set; } [XmlAttribute] public string[] StartSection { get; set; } } When serialized, I got something like that: <FrameSection Name="VAR1" StartSection="First circle Second circle"/> The problem is with deserialization, I got four items rather than two as space

How can I use serde to deserialize into a hierarchical decentralized configuration? [duplicate]

谁说我不能喝 提交于 2021-02-10 23:26:52
问题 This question already has answers here : How can deserialization of polymorphic trait objects be added in Rust if at all? (3 answers) How do I deserialize into trait, not a concrete type? (3 answers) Closed 6 months ago . I want to have a JSON config file of the form: { "general_option_foo": true, "general_option_bar": "hello world!", "modules": [ { "name": "moduleA", "module_options" : {"optFoo":"foo"} }, { "name" : "moduleB", "module_options" : {"optBar":[3,4], "optBuzz": true} } { "name":

How to serialize JSON with array field to object with String field?

北城以北 提交于 2021-02-10 14:16:42
问题 I have a JSON object like { "id" : "1", "children" : ["2","3"] } And I have a Java object like (constructor, getters and setters are omitted): public class Entity { public String id; public String children; } I want this JSON to be deserialized to my Java object by this code using Jackson: Entity entity = mapper.readValue(json, Entity.class); But get the following error: Can not deserialize instance of java.lang.String out of START_ARRAY token How can I solve it without changing type of

C# XML deserialization with namespace

风格不统一 提交于 2021-02-10 12:13:47
问题 I have XML: <?xml version="1.0" encoding="UTF-8"?> <gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"> <gesmes:subject>Reference rates</gesmes:subject> <gesmes:Sender> <gesmes:name>European Central Bank</gesmes:name> </gesmes:Sender> <Cube> <Cube time='2015-12-16'> <Cube currency='USD' rate='1.0933'/> <Cube currency='JPY' rate='133.18'/> </Cube> </Cube> </gesmes:Envelope> which I'm trying to deserialize with:

How to store ojalgo sparse array to file in java?

穿精又带淫゛_ 提交于 2021-02-10 12:01:47
问题 I currently have a SparseStore matrix on which I perform a lot of counting and calculations. I want to store it to file, so I can later reuse it without re-doing all previous calculations. I tried basic serialization in Java: ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(exportFileName)); outputStream.writeObject(mySparseStoreInstance); but it seems the class doesn't implement java.io.Serializable: java.io.NotSerializableException: org.ojalgo.matrix.store

How to store ojalgo sparse array to file in java?

流过昼夜 提交于 2021-02-10 12:01:25
问题 I currently have a SparseStore matrix on which I perform a lot of counting and calculations. I want to store it to file, so I can later reuse it without re-doing all previous calculations. I tried basic serialization in Java: ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(exportFileName)); outputStream.writeObject(mySparseStoreInstance); but it seems the class doesn't implement java.io.Serializable: java.io.NotSerializableException: org.ojalgo.matrix.store

The best way to store class instances to a file/database

落花浮王杯 提交于 2021-02-10 07:34:57
问题 What is the best way to store instances of a class to file/database? We have a base class called Command and loads of derived classes. Users create instances of these classes by adding commands to a graphical designer where they can configure them. (Set the properties). We then need a way to store these "commands" to a file without losing any information. One idea was to use db4o, but the GPL license is not acceptable for this project. Any suggestions or code samples? Update: (In order to "de