You are not logged in.
Pages: 1
Hi,
This is not a strictly mORM-ot related question, but could be seen as possible feautre request.
Is there any library to work with standard PHP serialized strings? This is how the serialized data looks like :
a:5:{s:8:"pa_meret";a:7:{s:4:"name";s:8:"pa_meret" ....
Leslie
Offline
I am looking into mORMot's serialization if there is an easy way to create a custom serialization for this. Some guidelines/examples could be useful.
Last edited by Leslie7 (2015-12-04 07:32:34)
Offline
ab,
Is there a deeper level entry point to start from for an alternate serialization? Is it a far strached attempt to create one if time is on short supply right now?
Offline
Just use json_encode and json_decode for PHP instead of serialize/unserialize.
Last edited by hnb (2015-12-04 08:23:37)
best regards,
Maciej Izak
Offline
I have no control over the php code on the server side. I just need to access the data in the database created by php serialization in my pascal code.
Offline
The PHP format is not that far from json. The major differences seem to be:
- the name -value pairs are separated by ";" instead of ":"
- there is a metadata prefix included everywhere. Eg
- for both the name and value : <datatype>:<datasize>
eg: JSON : {"aName":"aValue"}
PHP: {s:5:"aName";s:6:"aValue")
- for the collections/arrays : <a>:<element_count>
eg a:5{ ... }
This is the the syntax to be used:
String
s:size:value;
Integer
i:value;
Boolean
b:value; (does not store "true" or "false", does store '1' or '0')
Null
N;
Array
a:size:{key definition;value definition;(repeated per element)}
Object
O:strlen(object name):object name:object size:{s:strlen(property name):property name:property definition;(repeated per property)}
String values are always in double quotes
Array keys are always integers or strings
"null => 'value'" equates to 's:0:"";s:5:"value";',
"true => 'value'" equates to 'i:1;s:5:"value";',
"false => 'value'" equates to 'i:0;s:5:"value";',
"array(whatever the contents) => 'value'" equates to an "illegal offset type" warning because you can't use an
array as a key; however, if you use a variable containing an array as a key, it will equate to 's:5:"Array";s:5:"value";',
and
attempting to use an object as a key will result in the same behavior as using an array will.
Last edited by Leslie7 (2015-12-04 15:05:55)
Offline
Pages: 1