YAJL function for deleting node

Discussions relating to the ScottKlement.com port of the open source YAJL JSON Reader/Generator. This includes the YAJL tool as well as the YAJLR4, YAJLGEN, YAJLINTO and YAJLDTAGEN add-ons from ScottKlement.com. http://www.scottklement.com/yajl/
Post Reply
Isca
Posts: 1
Joined: Wed Jan 10, 2024 6:28 pm

YAJL function for deleting node

Post by Isca »

Hello everyone,

I'm starting with JSON manipulation and I need to modify a JSON by removing nodes from a list.
I wanted to know if there is an equivalent to yajl_array_delete in RPG 4, or other solutions?

Thanks in advance.
jonboy49
Posts: 206
Joined: Wed Jul 28, 2021 8:18 pm

Re: YAJL function for deleting node

Post by jonboy49 »

Directly within RPG your only option would be to use DATA-INTO with YAJLINTO to read the json, then copy only the required portions to a new DS and use DATA-GEN with YAJLGEN to regenerate the json. It is possible that you could achieve this without the use of a second DS by utilizing countprefix and setting the count for the array to zero.

I see no sign of the function yajl_array_delete - do you have the right name?
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: YAJL function for deleting node

Post by Scott Klement »

Something like this could be written, but it is an unusual request.

People normally store their records in a database or similar, not in a JSON document. Typically, your JSON document is created from the database on-the-fly when it is needed.

So if you had elements to delete, you'd delete them from the database. When you generate your JSON, they wouldn't be there because you generated from the database.

You might say the JSON document is an ephemeral document. It's typically just generated, sent over a network, and interpreted -- all within a second -- and that's the complete life of the document.
Post Reply