#1 2013-02-25 19:25:23

Sha
Member
From: Russia
Registered: 2012-01-07
Posts: 34
Website

How to check correctness of a custom unserialization of record?

I try to play with custom serialization of record as array of unnamed values.
If I correctly understand, for this purpose it is necessary to use RecordSaveJson.
The result, for example, is [365,-365,36.5,"2014-02-25T23:18:38","day\/3"]
For a unserialization I use RecordLoadJson. The result is expected.
The problem consists that it isn't clear how to check correctness of the received result.

Offline

#2 2013-02-26 10:54:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: How to check correctness of a custom unserialization of record?

You may have to call GetJSONField() by hand, and check if the content is correct.

Offline

#3 2013-02-26 20:57:59

Sha
Member
From: Russia
Registered: 2012-01-07
Posts: 34
Website

Re: How to check correctness of a custom unserialization of record?

I decided to use the simplified check on the basis of a trick with NULCHAR as in SynCommons.

The project below contains different variants of work with JSON.

http://guildalfa.ru/alsha/sites/default … onProj.zip

Offline

#4 2013-02-27 06:04:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: How to check correctness of a custom unserialization of record?

Sadly, the link just does not work...
"Страница не найдена", it says...
"Page not found", Google translates...

By the way, did you check the latest updates about UTF-8 in SynCommons.pas?
It now handles UTF-16 surrogates as expected, and also introduces some nice validation patterns within the process.
A good step forward, still using your speed enhancements patterns for ASCII 7-bit process.
See http://synopse.info/forum/viewtopic.php?pid=6597#p6597

Offline

#5 2013-02-27 19:46:28

Sha
Member
From: Russia
Registered: 2012-01-07
Posts: 34
Website

Re: How to check correctness of a custom unserialization of record?

Sorry.

Here some serialization examples   http://guildalfa.ru/alsha/sites/default … Proj_0.zip

and here annotation (in Russian)   http://guildalfa.ru/alsha/node/28

Thanks for the link. Very interesting. I will close read it and check UTF-updates in week.

Offline

#6 2013-02-28 09:36:51

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: How to check correctness of a custom unserialization of record?

Great post.

But, in fact, most of the dynamic array JSON serialization was already implemented within SynCommons.
Perhaps some kind of dynamic arrays (with smallint?) are not handled yet... but is it worth it?
I suspect there is no need to add a separate registration process, here.

I've added TTextWriter.AddDynArrayJSON() overloaded method and new function DynArrayLoadJSON() to be used e.g. for custom record JSON serialization, within TDynArrayJSONCustomReader/TDynArrayJSONCustomWriter callbacks.
They are just convenient functions to serialize/unserialize to/from JSON any dynamic array value, directly within the custom record serialization.
See http://synopse.info/fossil/info/beda33419e

Offline

#7 2013-02-28 17:16:38

Sha
Member
From: Russia
Registered: 2012-01-07
Posts: 34
Website

Re: How to check correctness of a custom unserialization of record?

In my source code I didn't use the predetermined types to show possibility of switching of data presentation.

Post is changed according to SynCommons changes.

For the best translation from/to Russian you can use   http://www.online-translator.com/Default.aspx/Text

Offline

#8 2013-02-28 23:11:59

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: How to check correctness of a custom unserialization of record?

That is a great idea.

Thanks!

:-)

Offline

#9 2013-03-01 01:41:40

ebz
Member
Registered: 2011-07-20
Posts: 18

Re: How to check correctness of a custom unserialization of record?

Thank you Sha, your source code help me a lot when dealing with JSON with SynCommons and friends

Offline

Board footer

Powered by FluxBB