Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2017-06

JSON SAX-based reader

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hello,

I have changed the JSON parser, it is now written on top of a SAX-like JSON reader (which is available separately). All unit tests work fine, and the few extra tests which I did also, but I would like to hear if someone has code that no longer works.

The change is committed in trunk. The new JSON reader is available in the unit jsonreader. Useful if you want to process large amounts of JSON data without building the whole JSON document in memory.

Michael.

Reply by email

Benito van der Zander
to Michael Van Canneyt

Hi,

Useful if you want to process large amounts of JSON data without building the whole JSON document in memory.

I have always used jsonscanner for that...

Best,
Benito

Michael Van Canneyt wrote 17 lines
Hello, I have changed the JSON parser, it is now written on top of a SAX-like JSON reader (which is available separately). All unit tests work fine, and the few extra tests which I did also, but I would like to hear if someone has code that no longer works. The change is committed in trunk. The new JSON reader is available in the unit jsonreader. Useful if you want to process large amounts of JSON data without building the whole JSON document in memory. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Michael Van Canneyt
to Benito van der Zander
Benito van der Zander wrote 7 lines
Hi, > Useful if you want to process large amounts of JSON data > without building the whole JSON document in memory. I have always used jsonscanner for that...

Well, JSONScanner does not do structural JSON validation. JSONReader does.
JSONReader of course uses JSONScanner to get the tokens.

Michael.

Reply by email

Stefan V. Pantazi
to Michael Van Canneyt: I have changed the JSON parser, it is now written on top of a SAX-like JSON reader (which…

Thank you for this, Michael. I think it is wonderful work.

I've done some old tests of the new implementation and it looks very good. The only failed tests were related to date and time representation. This appears to be fixed in the new version. Most importantly, I see no memory leaks when parsing fails due to malformed JSON, and that is great!

The only fixes I had to do to my own software to accommodate the new implementation, were:

1) comment out the "Strict" property of the TJSONParser (it appears it no longer exists); I used to set it to false, to allow for more flexibility in JSON syntax.

2) add the missing procedure SetKey(obj:TJSONObject); to TJSONConfig since it was removed from the new version of jsonconf.pp; anyway, in this particular case, it may be me that has to rethink and simplify my use of the json config component that does not need SetKey.

Hope this helps,

Stefan

Michael Van Canneyt wrote 16 lines
Hello, I have changed the JSON parser, it is now written on top of a SAX-like JSON reader (which is available separately). All unit tests work fine, and the few extra tests which I did also, but I would like to hear if someone has code that no longer works. The change is committed in trunk. The new JSON reader is available in the unit jsonreader. Useful if you want to process large amounts of JSON data without building the whole JSON document in memory. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________________

Reply by email

Michael Van Canneyt
to Stefan V. Pantazi
Stefan V. Pantazi wrote 14 lines
Thank you for this, Michael. I think it is wonderful work. I've done some old tests of the new implementation and it looks very good. The only failed tests were related to date and time representation. This appears to be fixed in the new version. Most importantly, I see no memory leaks when parsing fails due to malformed JSON, and that is great! The only fixes I had to do to my own software to accommodate the new implementation, were: 1) comment out the "Strict" property of the TJSONParser (it appears it no longer exists); I used to set it to false, to allow for more flexibility in JSON syntax.
It has been superseded by the more flexible 'Options' property since quite some time;
It was marked 'deprecated' in 3.0, and has now been removed in trunk.
Show quoted text 5 lines
2) add the missing procedure SetKey(obj:TJSONObject); to TJSONConfig since it was removed from the new version of jsonconf.pp; anyway, in this particular case, it may be me that has to rethink and simplify my use of the json config component that does not need SetKey.

The JSONConfig has not been changed recently, I suspect this change was already in 3.0.

Hope this helps,

It does, and I hope the above helps you in reviving your code :)

Michael.

Reply by email