serialization

passing a data structure from java to perl (and vice versa)

一个人想着一个人 提交于 2020-01-02 07:10:56
问题 A few days ago I asked about passing a data structure from java to perl and vice versa, and one of the recos was JSON. I played with it (mainly using Gson for java) and it seems quite nice. The only problem is I have references inside my data structure (to other objects inside the same data structure). Currently, each such reference is "translated" fully so actually each object is duplicated many times, and you can't tell all those references pointed to the same object. Is there someway to

Serialize deserialize anonymous child JSON properties to model

末鹿安然 提交于 2020-01-02 07:08:32
问题 I have an API I am receiving data from. That API is out of my control on how it is structured, and I need to serialize and deserialize the JSON output to map the data to my model. Everything works well where JSON is nicely formatted with named properties. What can you do where there is no named value and there is just an array of ints and strings? like under locations here is a sample of the JSON: {"id":"2160336","activation_date":"2013-08-01","expiration_date":"2013-08-29","title":"Practice

Serialize deserialize anonymous child JSON properties to model

狂风中的少年 提交于 2020-01-02 07:08:30
问题 I have an API I am receiving data from. That API is out of my control on how it is structured, and I need to serialize and deserialize the JSON output to map the data to my model. Everything works well where JSON is nicely formatted with named properties. What can you do where there is no named value and there is just an array of ints and strings? like under locations here is a sample of the JSON: {"id":"2160336","activation_date":"2013-08-01","expiration_date":"2013-08-29","title":"Practice

How do I add boost archive serialization support for boost fusion maps?

元气小坏坏 提交于 2020-01-02 06:57:11
问题 I'd like to add the functionality to be able to serialize boost fusion maps via the boost serialization interface. I've tried the following: #include <iostream> #include <boost/fusion/container/map.hpp> #include <boost/fusion/include/map.hpp> #include <boost/fusion/container/map/map_fwd.hpp> #include <boost/fusion/include/map_fwd.hpp> #include <boost/fusion/sequence/intrinsic/at_key.hpp> #include <boost/fusion/include/at_key.hpp> #include <boost/fusion/include/io.hpp> #include <boost/archive

Symfony 3.0.4 Circular reference detected during serialization with FOSRestBundle

守給你的承諾、 提交于 2020-01-02 06:10:53
问题 I'm using FOSRestBundle in a Symfony project. When it I try to handle a view, it fails during the serialization of my data with the Symfony serializer as well as with the JMSSerializer. This is the method rendering the response: DefaultController.php $em = $this->getDoctrine()->getManager('magellan'); $qb = $em->createQueryBuilder(); $query = $qb->select('h') ->from('DataBundle:Holding', 'h') ->where($qb->expr()->eq('h.id', ':holding_id')) ->setParameter('holding_id', $holding_id) ->getQuery(

Multiple namespaces with XmlSerializer

痞子三分冷 提交于 2020-01-02 05:47:25
问题 This is the scenario: I have nested classes and need to serialize then in an xml document [XmlRoot(Namespace="http://www.foo.bar/myschema")] public class root { [XmlAttribute] public string version { get; set; } [XmlElement] public child child { get; set; } ... } [XmlRoot(Namespace="http://www.foo.bar/myschema")] public class child { [XmlElement] public int elemA { get; set; } [XmlElement] public string elemB { get; set; } ... } I have created an method based in another example to remove

How do I Serialize Object to Database for Hibernate to read in Java

穿精又带淫゛_ 提交于 2020-01-02 05:31:54
问题 I'm currently writing a tool to plug into an existing enterprise application that uses Hibernate. My tool at install time needs to write some values into the database where one of the columns is a serialized version of a setting descriptor object. This object has two lists of objects and a few primitive types. My current approach is to create a ByteArrayOutputStream and an ObjectOutputStream and then write the ObjectOutputStream to the ByteArrayOutputStream , then passing the resulting byte

Serializing a very large list

非 Y 不嫁゛ 提交于 2020-01-02 04:56:09
问题 I'm gettint a large amount of data from a database query and I'm making objects of them. I finally have a list of these objects (about 1M of them) and I want to serialize that to disk for later use. Problem is that it barely fits in memory and won't fit in the future, so I need some system to serialize say the first 100k, the next 100k etc; and also to read the data back in in 100k increments. I could make some obvious code that checks if the list gets too big and then wirites it to file

Deserialize XML into Dictionary<string, string>

谁说胖子不能爱 提交于 2020-01-02 04:42:11
问题 I have some XML; <data> <name1>James</name1> <name2>John</name2> etc.. </data> The name1, name2, etc could be anything, i want to be able to get this xml into a dictionary ideally, is this possible using the built in .net serialisation? Thanks, James. EDIT: Ideally i dont want to use linq. Is it possible to serialise the whole element array to a string? So i'd end up with a string object 'Data' that contained all the child element tags and data? 回答1: No, but you can use Linq-to-Xml to do so:

Deserialize XML into Dictionary<string, string>

本小妞迷上赌 提交于 2020-01-02 04:42:06
问题 I have some XML; <data> <name1>James</name1> <name2>John</name2> etc.. </data> The name1, name2, etc could be anything, i want to be able to get this xml into a dictionary ideally, is this possible using the built in .net serialisation? Thanks, James. EDIT: Ideally i dont want to use linq. Is it possible to serialise the whole element array to a string? So i'd end up with a string object 'Data' that contained all the child element tags and data? 回答1: No, but you can use Linq-to-Xml to do so: