`
standalone
  • 浏览: 596039 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Serialize/Deserialize Perl Class Objects

    博客分类:
  • perl
阅读更多
Today in a small project I need to serialize a perl class object to string in order to cache it. And when getting back the value from the cache I need to deserialize it to original class objects.

There are good articles on the solutions:

http://www.ohmpie.com/serialization/

http://www.onperl.net/Serializing-and-Deserializing-using-Data-Serializer-pm

http://www.perlmonks.org/?node_id=8070

http://my.safaribooksonline.com/book/programming/perl/0596004567/objects-databases-and-applications/advperl2-chp-4-sect-2


First, I tried Data::Dumper which is quite simple. But if you class object has nested reference, when deserializing you will get 'undef' for the reference. E.g., if a part of the dumped sting is like this:

                      bless( {
                               'id' => '1',
                               'date' => '20130618',
                               'date_range' => $VAR1->{'logs'}[0]{'date_range'},
                             }, 'SiteLog::Entity::Log' ),


the data_range you get will be undef.


Finally I tried FreezeThaw, it works fine!
分享到:
评论

相关推荐

    Serialize and Deserialize Java 示例程序

    Serialize and Deserialize Java 示例程序。简单来讲,它的数据格式与json类似,但是在存储时对数字、多字节字符、数组等都做了很多优化,减少了无用的字符,二进制格式,也保证不用字符化带来额外的存储空间的增加...

    C#序列化与反序列化(Serialize,Deserialize)实例详解

    本文实例讲述了C#序列化与反序列化(Serialize,Deserialize)实现方法。分享给大家供大家参考。具体分析如下: 如果要保存运行程序过程的数据要么保存到数据库中,要么新建一个普通的文件,然后把数据保存进去.但是这...

    Android代码-Lyra

    Lyra supports automatic save/restore, base coders to serialize/deserialize values in Bundle, caching and retrieval of fields. Lyra includes a flexible API that allows developers to customize any ...

    Android代码-binaryprefs

    Binary Preferences Rapidly fast and lightweight re-...Small memory footprint while serialize/deserialize data Zero copy in-memory cache Persists only binary data. Not XML or JSON Out of box data

    java.lang.NoClassDefFoundError org.apache.xml.serializer.TreeWalker.doc

    在jsp运行过程中,报错 java.lang.NoClassDefFoundError org.apache.xml.serializer.TreeWalker时的处理方法。

    快速序列化/反序列化:这些函数可以将大多数 MATLAB 数据结构序列化为字节向量,反之亦然。-matlab开发

    这是 Tim Hutt 的 Serialize/Deserialize 函数的优化重写(它在神秘的数据结构上快了 10 倍)并支持一些额外的数据类型。 已知限制: * Java 对象不能被序列化* 超过 255 个维度的数组的最后一个维度被限制* 嵌套/...

    Android代码-yamlbeans

    YamlBeans makes it easy to serialize and deserialize Java object graphs to and from YAML, a human-friendly data format. Replace XML and properties files with YAML for more expressive power (lists, ...

    PHPSerializer.java

    php的serialize/unserialize,方便把一个数组序列化和反序列化,但是要和java交互,就比较麻烦了。通过这个工具类可实现很好的php与java的交互。 博客地址:...

    Serialize/Deseriali​ze:将几乎任何 matlab 变量编码和解码为字节序列。-matlab开发

    这对函数可以将几乎任何 matlab 对象序列化和反序列化(即编码和解码)成字节序列。 这对于将对象保存到磁盘、通过网络发送它们或发送到其他程序非常有用。 支持结构、单元格和矩阵的任何组合。...

    serialization-example:使用瞬态示例进行序列化和反序列化

    序列化http://localhost:8081/rest/serialize使用用户JSON的POST请求,例如{"name": "Sam", "dept", "Operation", "salary": 12000}反序列化http://localhost:8081/rest/deserialize -GET请求,该请求返回用户JSON,...

    .net Newtonsoft.Json 4.0 release

    you don't have a class to serialize or deserialize to, or the JSON is radically different from your class and you need to manually read and write from your objects. LINQ to JSON allows you to easily ...

    Json.NET 6.0 R3 For.NET(2.0-4.5)

    Json.NET Json.NET is a popular ... you don't have a class to serialize or deserialize to, or the JSON is radically different from your class and you need to manually read and write from your objects.

    matlab-json-master.zip_The Master_json matlab_matlab java class_

    This package contains Matlab class to serialize/decode matlab object in json format. The software uses org.json java package to convert json to java object and then translates it into Matlab object.

    opg:Rust OpenAPI 3.0文档生成器

    use serde :: {Serialize, Deserialize}; #[derive(Serialize, Deserialize, OpgModel)] #[serde(rename_all = "camelCase" )] #[opg( "Simple enum" )] enum SimpleEnum { Test, Another, Yay, } #[derive...

    BSONforJackson.zip

     //serialize data  ByteArrayOutputStream baos = new ByteArrayOutputStream();  ObjectMapper mapper = new ObjectMapper(new BsonFactory());  mapper.writeValue(baos, bob);  //deserialize...

    :locked_with_key: 加密所有的 Serialize。

    Alice Bob+-----------------------------------+ +-----------------------------------+| #[derive(Serialize, Deserialize)] | | #[derive(Serialize, Deserialize)] || struct Message | | struct Message |+--...

    Json NET 6 0 R8 For NET 2 0 4 5

    t have a class to serialize or deserialize to, or the JSON is radically different from your class and you need to manually read and write from your objects.">Json.NET is a popular high-performance ...

    Serialize-javascript.zip

    Serialize-javascript 能够序列化 JavaScript 库成含有正则表达式和功能的 JSON 包。示例:var serialize = require('serialize-javascript'); serialize({  str : 'string',  num : 0,  obj : {foo: ...

    Android代码-CacheUtilsLibrary

    This is a simple Android utils library to write any type of data into cache files and then read them later, using Gson to serialize and deserialize these data. 中文版请看这里。 Gradle compile '...

Global site tag (gtag.js) - Google Analytics