serialization

writeUTF(String s) vs writeObject(String s)

白昼怎懂夜的黑 提交于 2019-12-20 03:38:31
问题 In this Java project I'm working on for university, I have a situation where I am currently sending strings through the network successfully using streamOut = ObjectOutputStream streamIn = ObjectInputStream streamOut.writeUTF(msgs.peek()); where msgs is a linked blocking queue, receiving it with String in = streamIn.readUTF(); however, I would like to use an ObjectInputStream and an ObjectOutputStream. I have initialized them both in the constructor and I flush the ObjectOutputStream after

generating an safe hashcode for an objectgraph

旧巷老猫 提交于 2019-12-20 03:33:12
问题 I am importing some data from an file (xls, csv, xml) wich will result in a complex in-memory object graph. Now I need to know whether this graph has been modified since it once was exported. What would be a safe way to check this? I suppose I'd export a hashcode with the file? If so would the standard way of generating an object's hashcode suffice? How should I generate the hash? I would prefer to generate the hash on the object graph rather than on the actual stream/file. 回答1: You can

ExtensionDataObject not marked as serializable

与世无争的帅哥 提交于 2019-12-20 03:30:13
问题 Oi! I'm having issues serializing my session state. We have 2 components, our WCF and Web. Based on our AdministrationPartial.cs and Administration.svc we generate "Administration.cs" code for our web project with the following .bat file : svcutil.exe http://wcf_url.local/Administration.svc?wsdl /r:"{Path}\{Namespace}.dll" /d:"{Path}\{Namespace}\Code" I removed the personal data from the above statement and replaced it with {path} and {namespace}. The Administration.cs will be inside the Code

Invalid lambda deserialization

纵饮孤独 提交于 2019-12-20 03:26:30
问题 The Eclipse JDT compiler appears to have a problem whereby, under certain circumstances, Java 8 lamdas are not deserializing correctly and instead throw an IllegalArgumentException . I'm using the most recently distributed maintenance build, as follows: Eclipse SDK Version: Luna SR2 (4.4.2) Build id: M20141210-0900 There are existing bugs / SO entries that report similar issues that have been (at least partially) resolved in Luna SR2 (4.4.2) M20141210-0900 . I have personally verified that

Swift JSON Serialization typeMismatch

▼魔方 西西 提交于 2019-12-20 03:17:35
问题 Currently struggling how to use Decodable. I've done some googling to the errors I'm getting but I still believe that the way i'm structuring the structs isn't correct but it seems to make sense to me. I've also tried using optionals In the error that I've posted at the end, I'm confused about the reference to the Double type. As I don't have any type or anything int he response that uses a double. (I'm also able to serialize the json reponse using the old swift method of casting the data as

Where do I change the setting in Eclipse so that it would generate serialVersionUID for Serializable classes?

非 Y 不嫁゛ 提交于 2019-12-20 03:17:29
问题 I want Eclipse to generate a serialVersionUID for classes that implement Serializable . However, my Eclipse instance does not throw me a warning or an error when I create a class that implements Serializable . Also, it does not give an suggestion about adding a generated serialVersionUID . Where do I change the required setting? 回答1: To turn on warning for Serializable class without a serialVersionID, go to Window > Preference > Java > Compiler > Errors/Warnings and search for Serializable

How to serialize a linked list implemented in java?

ε祈祈猫儿з 提交于 2019-12-20 03:14:45
问题 I read online that serialization can be omitted for derived objects by declaring them as transient. But, in case of linked list the links are memory references between objects. So, should I convert it to array and store the array representation? 回答1: Here's how Java serializes LinkedList : it fetches all elements and writes them to the ObjectOutputStream , together with the size. And of course declares the header entry transient See the writeObject and readObject methods of LinkedList : //

When using jsonlite in R, how do I specify that only some of the entries are to be treated as arrays?

有些话、适合烂在心里 提交于 2019-12-20 03:11:56
问题 I have the following code: # install.packages("jsonlite") require("jsonlite") x = list( test = "my_test", data = c(1, 2, 3) ) toJSON(x) This prints: {"test":["my_test"],"data":[1,2,3]} I was expecting: {"test":"my_test","data":[1,2,3]} I've tried using some of the parameters from the documentation, but can't seem to get it right. 回答1: The argument auto_unbox=TRUE did the trick: automatically unbox all atomic vectors of length 1. It is usually safer to avoid this and instead use the unbox

JSONEncoder's dateEncodingStrategy not working

随声附和 提交于 2019-12-20 02:59:08
问题 I am trying to serialize a struct to a String using Swift 4's Encodable+JSONEncoder. The object can hold heterogenous values like String, Array, Date, Int etc. The used approach works fine with the exception of Date. JSONEncoder's dateEncodingStrategy property is not having any effect. Here is a snippet which reproduces the behaviour in Playground: struct EncodableValue:Encodable { var value: Encodable init(_ value: Encodable) { self.value = value } func encode(to encoder: Encoder) throws {

PHP SQLite JSON Data Duplication

寵の児 提交于 2019-12-20 02:58:24
问题 I have the following PHP code: $testMessage = "TESTMESSAGE"; $db = new SQLite3('messages.sq3'); $db->exec('CREATE TABLE messages(id INTEGER PRIMARY KEY, message CHAR(255));'); $db->exec("INSERT INTO messages (message) VALUES ('$testMessage');"); $results = $db->query('SELECT * FROM messages ORDER BY id DESC LIMIT 5'); while ($row = $results->fetchArray()) { print_r($row); } The resulting print_r: Array ( [0] => 1 [id] => 1 [1] => TESTMESSAGE [message] => TESTMESSAGE ) Why is this data