serialization

C++ Boost::serialization : How do I archive an object in one program and restore it in another?

白昼怎懂夜的黑 提交于 2021-02-08 09:15:24
问题 I'm using Boost Serialization for saving and loading my game's overall state as well as storing map and creature data externally. I have two programs. The first runs the game itself, creating new objects as necessary based on the data saved in the external files. It also produces savefiles of its own state. These all work so far. The second, I am creating as a dedicated editor. I want to use it to create and manipulate said files to be used by the game program. So I made mirror images in the

Java GSON - serialize int as strings to json file

烈酒焚心 提交于 2021-02-08 06:43:28
问题 I have this Java class: class Car { int mileage; int id; } When I tell gson to serialize it, it of course serializes it to: { "mileage": 123, "id": 12345678 } But what if I want to serialize it to: { "mileage": "123", "id": "12345678" } Assuming changing my members from int to String, is not an option, is there a way to tell gson to serialize those int members as strings to the json file? 回答1: There are likely many ways to achieve what you desire. I will share two ways. FIRST - Using Custom

How do I pass a class object in a argument list to a another computer and call a function on it?

筅森魡賤 提交于 2021-02-08 06:39:38
问题 I am attempting to create a class object and use Invoke-Command to call a function on the class on a remote machine. When I use Invoke-Command with no computer name this works fine but when I attempt to do this on a remote computer I get an error saying the that the type does not contain my method. Here is the script I am using for testing this. $ComputerName = "<computer name>" [TestClass]$obj = [TestClass]::new("1", "2") Get-Member -InputObject $obj $credentials = Get-Credential Invoke

How to serialize a nest js response with class-transformer while getting data with Typegoose?

帅比萌擦擦* 提交于 2021-02-07 20:13:34
问题 I have been trying to work through the NestJs example for the Serialization Section for Mongodb using Typegoose using the class-transformer library. The example given at https://docs.nestjs.com/techniques/serialization only shows how to use serialization in TypeORM. I followed the same process for Typegoose. Here is what I have tried so far. // cat.domain.ts import { prop } from '@typegoose/typegoose'; export class Cat { @prop() name: string; @prop() age: number; @prop() breed: string; } //

How can I link two Java serialised objects back together?

喜欢而已 提交于 2021-02-07 11:57:14
问题 Sometimes (quite a lot, actually) we get a situation in Java where two objects are pointing to the same thing. Now if we serialise these separately it is quite appropriate that the serialised forms have separate copies of the object as it should be possible to open one without the other. However if we now deserialise them both, we find that they are still separated. Is there any way to link them back together? Example follows. public class Example { private static class ContainerClass

Subtype fieldnumber order dependent in protobuf-net

岁酱吖の 提交于 2021-02-07 08:53:39
问题 I can see that protobuf-net seems to need to have deterministic ordering on the run type model. What's a good strategy to use without the need of having attributes on each class for the ordering. How does protobuf it self do if it were that you were implementing by attributes instead ? model.Add(typeof(IMessage), false).AddSubType(8500, typeof(DogBarkedEvent)); model.Add(typeof(IMessage), false).AddSubType(8501, typeof(DogBarkedEvent2)); if I create a new model and try to deserialize with

Subtype fieldnumber order dependent in protobuf-net

强颜欢笑 提交于 2021-02-07 08:52:36
问题 I can see that protobuf-net seems to need to have deterministic ordering on the run type model. What's a good strategy to use without the need of having attributes on each class for the ordering. How does protobuf it self do if it were that you were implementing by attributes instead ? model.Add(typeof(IMessage), false).AddSubType(8500, typeof(DogBarkedEvent)); model.Add(typeof(IMessage), false).AddSubType(8501, typeof(DogBarkedEvent2)); if I create a new model and try to deserialize with

Subtype fieldnumber order dependent in protobuf-net

北城以北 提交于 2021-02-07 08:52:00
问题 I can see that protobuf-net seems to need to have deterministic ordering on the run type model. What's a good strategy to use without the need of having attributes on each class for the ordering. How does protobuf it self do if it were that you were implementing by attributes instead ? model.Add(typeof(IMessage), false).AddSubType(8500, typeof(DogBarkedEvent)); model.Add(typeof(IMessage), false).AddSubType(8501, typeof(DogBarkedEvent2)); if I create a new model and try to deserialize with

HashMap serialization and deserialization changes

谁都会走 提交于 2021-02-07 07:39:28
问题 We are working with an in memory data grid (IMDG) and we have a migration tool. In order to verify that all the objects are migrated successfully, we calculate the chucksum of the objects from its serialized version. We are seeing some problems with HashMap, where we serialize it, but when we deserialize it the checksum changes. Here is a simple test case: @Test public void testMapSerialization() throws IOException, ClassNotFoundException { TestClass tc1 = new TestClass(); tc1.init(); String

cPickle - different results pickling the same object

送分小仙女□ 提交于 2021-02-07 05:52:29
问题 Is anyone able to explain the comment under testLookups() in this code snippet ? I've run the code and indeed what the comment sais is true. However I'd like to understand why it's true, i.e. why is cPickle outputting different values for the same object depending on how it is referenced. Does it have anything to do with reference count? If so, isn't that some kind of a bug - i.e. the pickled and deserialized object would have an abnormally high reference count and in effect would never get