I have been working on JSON arrays with the help of a very helpful member (Who wrote part of this code) and so far I have this:
Code: Select all
[h: key="name"]
[H: status = input(
"value | | Equipment to find | TEXT | WIDTH=15"
)]
[r: indexvalue = replace(json.path.read(myData,strformat("\$[?(@.['%s'] == '%s')]",key,value),"ALWAYS_RETURN_LIST,AS_PATH_LIST,SUPPRESS_EXCEPTIONS"),"[^0-9]","")]
So, I need to make 3 changes. Please, in the interest of me learning from the changes if you don't mind posting the code between each change (if you make the changes for me that is)?
First (Because I think change 3 may be very hard, or it may be very easy) it needs to change so if the key CONTAINS the value to return the index number. For example. lets say the array contains a key with the value "Quarterstaff", if I imputed "Quarter" it would return the index value (I hope thats clear)
Second, It needs to be case insensitive. "Quarterstaff" and "quarterstaff" and "QUARTERSTAFF" need to be all the same.
Finally, (I suspect this will be very easy, or very hard) it needs to separate each index with a , (Well, with anything I would guess, but , is just ideal) so instead of returning "122" it would return "1,22" Even if it end up returning "1,22," it will be fine; I can strip out the last comma myself.
If someone doesn't mind making the changes, that would be amazing as I can learn from studying the differences. Or baring that assisting me to make the changes myself.
A big advance thank you.