-
Notifications
You must be signed in to change notification settings - Fork 263
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
json.get no longer interprets string/number as an array of size 1 #1144
Comments
I’m inclined to go with the 1.5.10 functionality as a bug. Anyone else want to chime in? |
That was my first thought as well but I bet changing the behavior will break frameworks. |
I’m only about 20% worried about that. If a FW breaks, they were relying on undocumented implementation artifacts. (We didn’t document it to work like that, I hope?) And I doubt anyone would write code like that and actually expect that result! |
If it could break frameworks, maybe the change should be punted to 1.6 in the interest of semantic versioning? It seems reasonable if it would technically be breaking backward-compatibility a tiny bit, even if it isn't intended behavior. I'm not attached to it going in now or later, but I think the idea is worth mentioning. |
There are several functions that treat "string" as an array of 1 item.
|
It may be bad coding, but that's our audience. |
In my case, the issue occurred because of Hence the following code results in an error in 1.5.11 (but not 1.5.10) if
Thankfully, now that |
Well, waiting for 1.6 isn’t terrible either, since that’s likely just around the corner. But I don’t any skin in this game, so while I have an opinion, it’s all that I have! I’ll defer to the people that write MTscript. Since @aliasmask says there are others that work the same way, I’m inclined to leave it (otherwise, we should change all of them). |
I don't really see any harm in continuing with the way it has worked in the past. |
I will fix it to preserve compatibility |
I've recently been caught being lazy with json.contains where if you use "" for your empty array it will toss back an error. For example, if I get a token property where it either doesn't exist or has a json array I have to do some validation to change to "[]" if empty so my code doesn't break later on.
|
Tested. Working as before. |
- Add unit tests to prevent regressions of recent json bug fixes (RPTools#1121, RPTools#1125, RPTools#1139, RPTools#1143, RPTools#1144, RPTools#1151, RPTools#1167, RPTools#1177)
Describe the bug
The function
json.get
no longer implicitly converts strings/numbers to arrays of size 1.Previously,
json.get(string, 0)
would return thestring
, andjson.get(number, 0)
would return thenumber
. Now it gives an error instead.To Reproduce
Steps to reproduce the behavior:
[r: json.get("test", 0)]
Argument number 1 to function "json.get" must be a JSON Array or Object.
test
.Expected behavior
json.get
works like it did in 1.5.10.MapTool Info
Desktop:
Additional context
The new behavior may be preferable to the previous one. If we keep it, the change logs should document the new behavior of
json.get
.The text was updated successfully, but these errors were encountered: