Hey GetMem,
I don't smoke, but maybe I was drunk.
LOL
Touché
It makes sense to me, the JSON is directly parsed into an object, instance of a class to be more precise. Please take a look at opkman_serializablepackages.pas for more details. The number in the end makes the JSON validators happy, like this one: https://jsonlint.com/.
Of course it makes sense to you, LOL, you were the one that came up with it, eheheh!!!
Nonetheless, making an object with infinite members is just odd when you could just have an array of objects.
This array of objects could then be nicely un-marshaled into a
TObjectList, or a
TFPObjectList or even using generics a
TFPGObjectList.
It then can be tracked so much easily with an index on the
Items default property. It even marries well with the
ItemIndex of a
TListBox or any other component that will have a corresponding thing.
I've been doing a ton of marshaling and un-marshaling of JSON and I welcome the nicety of an array of objects getting translated to a collection of Objects in Pascal.
Your solution works, obviously, but I'm guessing that you never considered that your JSON would be used by anyone but yourself, which, again, is rather understandable
I will, eventually, have a look at
opkman_serializablepackages.pas, cuz I need to finish my
setup-lazarus GitHub action to implement dependencies and multi-packages. ATM its failing rather embarrassingly on that aspect.
Maybe before I complete the setup-lazarus GH Action, I'll probably write a bit of code that will translate your massive Father Object into a TFPObjectList of custom made Object Pascal classes that will support your JSON data in a manner that is more bag of objects, than object of objects, if that makes sense
And this translation work could be the beginning of a command line package manager. Maybe
opm-cli or something of the sorts
There's a person on the Discord server that really doesn't like Lazarus. He prefers VS Code/Vim cuz for his needs the GUI is un-welcomed. He proclaims to be a CLI man only
There is already a Python command only package manager, called LPM(
Lazarus Package Manager), made by Warfley, that has the option to use your JSON data and can also get stuff from GitHub, but a native Object Pascal solution wouldn't be a bad thing, right?
No problem. Constructive criticism is always good.
I'm so glad you took it that way, cuz it is what I intended
Cheers,
Gus