Sign in Join

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

Mailing lists / fpc-pascal / 2019-08

A new design for a JSON Parser

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Anthony Walter

I know the FCL already has a capable JSON parser, but I am writing some Amazon web service interfacing projects and wanted a smaller easier to use JSON parser to assist. I've create a new design for a JSON parser that is pretty small, yet powerful.

If your interested, I've posted the code under GPLv3 and a write up of my thought process and the workflow of using an single small class to work with JSON:

https://www.getlazarus.org/json/

Any and all feedback is welcome.

Zamrony P. Juhara
to Anthony Walter

Very cool library.
It would be nice if separator character can be change For example, for me personally
aval := n.find('billTo.name'). value;
more intuitive instead of
aval := n.find('billTo/name'). value;

Also AFAIK, GPL v3 license will require application using this library must use GPL too.

Zamrony P. Juhara
Fano Framework https://fanoframework.github.io

On Mon, Aug 26, 2019 at 15:12, Anthony Walter wrote: I know the FCL already has a capable JSON parser, but I am writing some Amazon web service interfacing projects and wanted a smaller easier to use JSON parser to assist. I've create a new design for a JSON parser that is pretty small, yet powerful. If your interested, I've posted the code under GPLv3 and a write up of my thought process and the workflow of using an single small class to work with JSON: https://www.getlazarus.org/json/

Any and all feedback is welcome._______________________________________________ fpc-pascal maillist  - 
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Anthony Walter
to Zamrony P. Juhara

Adding a global redefinable separator character is a good idea which I might add. With regards to using the forward slash, I am just reusing the XPath way of doing things and was considering adding a few more XPath like queries. For example:

N.Find('/inventory/999/sku'); // search from root if the first path
character is '/', find the 999th node, return the sku
N.Find('//item[name="widget"]/price'); // search for the first item in the
entire document ('//') with a name of widget, return its price
N.Find('//item[recalled]/name'); // search for the first item with a
recalled node and return the name

And so on ...