[Top][All Lists]

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

Re: string serialization of builtin datatypes

From: Philip Nienhuis
Subject: Re: string serialization of builtin datatypes
Date: Wed, 06 May 2015 22:39:58 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0 SeaMonkey/2.33

Oliver Heimlich wrote:
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?

<io pkg maintainer here>

If a number of devs think that io would be a good or maybe even the best place, just prepare a cs. But only if it is properly documented, contains tests or some other way to validate proper operation, and there's someone who maintains it (not necessarily the author).

In io there's already a JSON function. I know vaguely what it does (objects to JSON conversion) but have no idea about relative quality. It may well be that it is effectively unmaintained ATM. It does have a few tests.
I just package it with the rest and hope for the best :-)

FYI: I plan to make a 2.2.8 io release around May 20 or so (hopefully in time for Octave-4.0.0 final), after I'm back from a trip abroad.


reply via email to

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