Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Merge Json" block #1609

Open
snowboyz0825 opened this issue Jul 14, 2024 · 7 comments
Open

"Merge Json" block #1609

snowboyz0825 opened this issue Jul 14, 2024 · 7 comments

Comments

@snowboyz0825
Copy link

We should implement a "merge json" block, which would do as the name entails. You would probably have to pick between allowing duplicates or not, and maybe an input for how "deep" you would want it. Also, before anyone says you could already achieve this with custom reporters, you can technically do the entire json extension with custom reporters so that's not really a valid arguement

@RockyTheProtogen
Copy link

you can technically do the entire json extension with custom reporters so that's not really a valid arguement

No, it doesn't invalidate that argument.
Here:
block_7_18_2024-11_04_31 AM

@snowboyz0825
Copy link
Author

you can technically do the entire json extension with custom reporters so that's not really a valid arguement

No, it doesn't invalidate that argument. Here: block_7_18_2024-11_04_31 AM

This is not merging jsons, just looking at it this is a fancy way of joining them together. Merging jsons would be similar to merging folders - any keys would be set to the answer of that key plus the answer of another key, a lot like subdirectories. I suppose, however, that this would probably work for most purposes, as getting all keys of something would probably get the answers to multiple keys of the same name, so I may close this issue.

@snowboyz0825
Copy link
Author

Just testing it, if we try to get the value {"key":"value","badkey":"badvalue","key":"value2"} (I did not try merging, yet, this is just some proof testing) it will only give the value of the final key of that name - e.g if we try to get the value of "key" it will only give "value2".

If we were to merge {"key":"value","badkey":"badvalue"} and {key:value2} it should result in {"key":"[value,value2]",badkey":"badvalue"}

This would likely have to extend to subvalues, e.g {"key":{"inkey":"invalue"}} and {"key":{"inkey":"invalue2","otherkey":"othervalue"}} would merge to {"key":{"inkey":["invalue","invalue2"],"otherkey":"othervalue"}}.

I'm not a real programmer by any means, I'm not even that great at turbowarp, but this seems like something that most json libraries (I think that's the right term but probably not) would have already. This may be too hyper specific to add to an extension and if it is, I completely understand. There are multiple issues such as how to hand true/false, weather or not to merge into an array or keep one value, and probably more I haven't thought of.

@namelessisbackbutnottodobadthingsiswear

you can technically do the entire json extension with custom reporters so that's not really a valid arguement

No, it doesn't invalidate that argument. Here: block_7_18_2024-11_04_31 AM

I know OP already assessed that this isn't the function they were thinking of, but this still feels like a rather roundabout solution for something that should be simple. Perhaps another issue regarding this topic is in order.

@Skyhigh173
Copy link
Contributor

It is included in v2.6 but haven't merged yet :(

@Mistium
Copy link

Mistium commented Aug 22, 2024

This is possible using patching, and custom blocks. Demonstrated below:

block_22_08_2024-09_19_23

@Mistium
Copy link

Mistium commented Aug 22, 2024

just not the simplest thing to set up. and you need to know js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants