JSON extender request

Started by bottomleypotts, June 27, 2025, 05:07:33 AM

Previous topic - Next topic

bottomleypotts

Now that we have Maps that can contain arrays and other maps, is there a chance jsParse (or we could call it jsExtendedParse) that could just create a map that contains other maps or arrays. Rather than having to hack our way through it all manually?

Also, so that I can use jsKeyPaths more usefully when I enumerate the entire JSON, could we just have one extra function. To be able to tell how many array elements exist? Add the ".length" element please?

Thank you for listening.

spl

Quote from: bottomleypotts on June 27, 2025, 05:07:33 AMTo be able to tell how many array elements exist? Add the ".length" element please?

Thank you for listening.

So you are asking, if a json element is an array then how many items in that element? But if an item was a sub-array etc.. the task gets more complicated. I worked with Jira json returns and an element can often be nested 4-5 levels. Not sure parsing something like that would be the job of an Extender function, but rather some clever udf's. Just .02
Stan - formerly stanl [ex-Pundit]

td

I agree. You can write a UDP or two to parse pairs returned by the extender. All paths in a JSON dataset can be returned using jsFindPaths with an empty string as the search target. The number of elements in a JSON array is returned by jsGetInfo using request 4.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

spl

Quote from: td on June 27, 2025, 07:39:08 AMI agree. You can write a UDP or two to parse pairs returned by the extender. All paths in a JSON dataset can be returned using jsFindPaths with an empty string as the search target. The number of elements in a JSON array is returned by jsGetInfo using request 4.

Yeah .Count not .Length
Stan - formerly stanl [ex-Pundit]

td

ArrInfo can get the "length" of a JSON container object, since it is returned as a WIL map.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

bottomleypotts

What I would like is a simple way to navigate json. Didn't think that would be a problem.

And of course I can parse the json myself. How do you think I'm doing it now?

But thanks for the suggestion of jsFindPaths. Where does this exist exactly?

And no .count is not a built-in property like .length in JavaScript. So maybe I was referring to this???

spl

Quote from: bottomleypotts on June 27, 2025, 11:01:00 PMAnd no .count is not a built-in property like .length in JavaScript. So maybe I was referring to this???

I made a poor joke there. Had several instances where I forgot length = count. As for a simple way to navigate any given json, probably a holy grail. As json is a preferred response for API requests creating a schema to assist with eventual parsing for each API lends itself to a couple of generic UDF's. Be worth exploring if the Json Extender can help with schema creation. Last year I wrote a script to create json output describing WB 64bit dll's - which I used to play with the Extender... very challenging

unzip attached for a look-see
Stan - formerly stanl [ex-Pundit]

td

Quote from: bottomleypotts on June 27, 2025, 11:01:00 PMWhat I would like is a simple way to navigate json.

Ask ChatGPT, Copilot, Claude, or whatever to write something for you.  We promise not to be offended.

Quote from: bottomleypotts on June 27, 2025, 11:01:00 PMBut thanks for the suggestion of jsFindPaths. Where does this exist exactly?

Scroll down the link's page for a mention of using an empty string.

https://docs.winbatch.com/mergedProjects/Json/jsKeyPasths.htm

Another maybe useful JSON parsing function that was added in version 44009. It does require using a WIL pointer parameter, which some users find confusing, but I suspect that is not an issue in this case.

https://docs.winbatch.com/mergedProjects/Json/jsKeyExist.htm

Nested WIL maps are a relatively new feature in WinBatch. They may be included as an option in the JSON extender sometime in the future. 


"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

spl

Quote from: td on June 28, 2025, 07:27:48 AMNested WIL maps are a relatively new feature in WinBatch. They may be included as an option in the JSON extender sometime in the future. 


So a ConvertToJson(map_or_array,Output_json) would be exciting.
Stan - formerly stanl [ex-Pundit]

SMF spam blocked by CleanTalk