sbcgua / ajson

Yet another json parser serializer for ABAP
MIT License
49 stars 15 forks source link

Metadata methods? #145

Closed G3GDan closed 1 week ago

G3GDan commented 1 year ago

This is a query rather than an issue. I'm using ajson to parse data which arrives as nested collections. Currently accessing the data in MT_JSON_TREE to obtain the number of Children for processing in a do loop. I then construct the expected path values in turn before various calls to get() methods.

Is there a benefit to a method which returns the number of Children? There is already get_node_type() but possibly other metadata could be exposed in a similar way.

I realise another option is for me to call exists() for each path and exit my loop once I reach the last member in the collection. Or possibly members() may offer another way.

Happy to submit my implementation for get_node_children() - but it will be fairly trivial!

mbtools commented 1 year ago

The members function should do the trick. Here's an example of how I use it:

https://github.com/Marc-Bernard-Tools/ABAP-Lint-Ext-for-abapGit/blob/2e952607e7efc8ae7b5c95bd852f583396122489/src/zcl_abaplint_abapgit_ext_chkrn.clas.abap#L73-L111

G3GDan commented 1 week ago

Thought I'd better report back...

Yes, using members works well. For various reasons it has taken us a while to get to the stage of implementing a new version of our code.

As there didn't seem to be a need/enthusiasm for metadata methods, let's close this.