[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string serialization of builtin datatypes

From: Oliver Heimlich
Subject: Re: string serialization of builtin datatypes
Date: Wed, 06 May 2015 20:20:52 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0

On 06.05.2015 19:47, Andreas Weber wrote:
Dear users,

I once wrote a serialize function
( to get a human readable string
representation of built in datatypes. To restore the var just call eval.
The intended purpose is to serialize objects for transmission over
byte-stream channels (serial, tcp...) or for storage in databases while
perserve the readability by humans(in contrast to the usage of
typecast(x, "uint8" for example).

Does anyone see an octave-forge package this might fit in?


the function might fit into the io package, but I am not sure.

Some remarks for improvement of the function:
- If you want to ensure exact restoration of the original value, you certainly want to increase the precision during the call to mat2str for binary64 numbers. - Also you should vectorize function evaluation with the usage of cellfun/structfun instead of for-loops.

btw: Do we have a function which checks a string for malicious code
before evaluating? For example wget, system, unlink and so on.

I don't think it exists. This is the big disadvantage of serializing data into code that has to be eval'ed. Did you try JSON or YAML as a readable kind of serialization?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]