deserialization

Django caching a large list

妖精的绣舞 提交于 2019-12-21 17:18:29
问题 My django application deals with 25MB binary files. Each of them has about 100,000 "records" of 256 bytes each. It takes me about 7 seconds to read the binary file from disk and decode it using python's struct module. I turn the data into a list of about 100,000 items, where each item is a dictionary with values of various types (float, string, etc.). My django views need to search through this list. Clearly 7 seconds is too long. I've tried using django's low-level caching API to cache the

Jackson polymorphic deserialization with nested type info property

旧街凉风 提交于 2019-12-21 12:01:21
问题 I'm constrained by the given JSON structure: { "metadata": { "eventName": "FooEvent", "field1": "bla" }, "event": { ... } } How can I deserialize it using polymorphic deserialization and nested type info property? I'm using metadata.eventName nested property in @JsonTypeInfo like this: @JsonTypeInfo( use = Id.NAME, include = As.EXISTING_PROPERTY, visible = true, property = "metadata.eventName" ) @JsonSubTypes({ @Type(name="fooEvent", value = FooEvent.class) @Type(name="barEvent", value =

JMS Serializer Deserialize with abstract parent class

蓝咒 提交于 2019-12-21 09:31:27
问题 I have an abstract parent (mapped super-)class which has several children with different properties which I'd like to deserialize. I'm storing the data using MongoDB and Doctrine ODM, so I also have a discriminator field which tells doctrine which subclass is used (and also have a custom "type" property ontop which is used elsewhere to determine which class is currently processed). When deserializing my model, I get an exception telling me that its impossible to create an instance of an

“Invalid field in source data: 0” error with ProtoBuf-Net and Compact Framework

谁都会走 提交于 2019-12-21 07:44:50
问题 Is anyone aware of any issues when using ProtoBuf-Net to serialize/deserialize between compact framework and the full .Net framework? I have a class called LogData that I am serializing under compact framework 3.5, transmitting to a server (running .Net framework 4.0), which then deserializes. Sometimes it works and sometimes it throws the above error and I have yet to narrow it down to any specific cause. I've done many many tests with different values and can't seem to find any rhyme or

“Invalid field in source data: 0” error with ProtoBuf-Net and Compact Framework

馋奶兔 提交于 2019-12-21 07:41:13
问题 Is anyone aware of any issues when using ProtoBuf-Net to serialize/deserialize between compact framework and the full .Net framework? I have a class called LogData that I am serializing under compact framework 3.5, transmitting to a server (running .Net framework 4.0), which then deserializes. Sometimes it works and sometimes it throws the above error and I have yet to narrow it down to any specific cause. I've done many many tests with different values and can't seem to find any rhyme or

Jackson JSON + Java Generics

我只是一个虾纸丫 提交于 2019-12-21 07:04:43
问题 I am trying to deserialize/map the below JSON to List<Bill > java object using Jackson json library . (this json was generated by jackson, Iam omitting that piece for brevity) {"bills":[{"amount":"13","billId":"billid3"}]} Here is my conversion method: private static void convert(){ String jsonBill = "{\"bills\":[{\"amount\":\"13\",\"billId\":\"billid3\"}]}"; ObjectMapper mapper = new ObjectMapper(); List<Bill> bills = null; try { bills = mapper.readValue(jsonBill, new TypeReference<List<Bill

Json string deserialized to array list of objects

吃可爱长大的小学妹 提交于 2019-12-21 06:45:01
问题 Please help! Getting this error on Deserializing: Cannot convert object of type 'System.String' to type 'System.Collections.Generic.List' JSON string from client: "\"[{\\"id\\":\\"18_0_2_0\\",\\"ans\\":\\"You can enter free text in place of * \\"},{\\"id\\":\\"23_1_3_1\\",\\"ans\\":\\"The refresh button\\"},{\\"id\\":\\"11_2_1_2\\",\\"ans\\":\\"False\\"}]\"" Edit: Unescaped (see comments): [{"id":"18_0_2_0","ans":"You can enter free text in place of * "},{"id":"11_2_1_2","ans":"False"}]

Json string deserialized to array list of objects

旧城冷巷雨未停 提交于 2019-12-21 06:43:15
问题 Please help! Getting this error on Deserializing: Cannot convert object of type 'System.String' to type 'System.Collections.Generic.List' JSON string from client: "\"[{\\"id\\":\\"18_0_2_0\\",\\"ans\\":\\"You can enter free text in place of * \\"},{\\"id\\":\\"23_1_3_1\\",\\"ans\\":\\"The refresh button\\"},{\\"id\\":\\"11_2_1_2\\",\\"ans\\":\\"False\\"}]\"" Edit: Unescaped (see comments): [{"id":"18_0_2_0","ans":"You can enter free text in place of * "},{"id":"11_2_1_2","ans":"False"}]

How to create a DataTable based on the Json deserialized JArray Data?

…衆ロ難τιáo~ 提交于 2019-12-21 06:05:17
问题 I have fallowing JArray data. I need to create a datatable dynamically based on the column names in the Jarray, after that I need to insert the data. Can you please help me to do this operation. <pre> {[ { "PID": 3, "FirstName": "parveen", "LastName": "a", "Gender": "male" }, { "PID": 8, "FirstName": "ramarao", "LastName": "M", "Gender": "male" } ]} </pre> Thanks in advance purna 回答1: Your JSON input is not valid. You should remove the first and the last brackets, since it is an array, not an

Weird serialisation behavior with HashMap

主宰稳场 提交于 2019-12-21 05:05:50
问题 Consider the three following classes: EntityTransformer contains a map associating an Entity with a String Entity is an object containing an ID (used by equals / hashcode), and which contains a reference to an EntityTransformer (note the circular dependency) SomeWrapper contains an EntityTransformer , and maintains a Map associating Entity 's identifiers and the corresponding Entity object. The following code will create an EntityTransformer and a Wrapper, add two entities to the Wrapper,