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

Fix json.* constants to keep a GSON representation #4247

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Aug 14, 2023

Identify the Bug or Feature request

Fixes #4161

Description of the Change

When looking up a variable (including constants), we preserve JsonArray and JsonObject values rather than converting them strings. The same functionality is now extended to JsonNull and boolean JsonPrimitive.

I could have altered the checks to a single JsonElement, but I'm not confident whether changing other primitive JSON values (numbers) could cause issues. So instead I have chosen to be more precise and only accomodate the needs of json.null, json.true, and json.false, leaving the behaviour of JSON numbers to be unchanged.

No other changes have been made to functions or MTScript-JSON conversion, notably:

  • json.get() and similar functions will still convert returned null, true, or false to the MTScript strings "null", "true", and "false".
  • MTScript strings "null", "true", "false" will not be converted to JSON null, true, or false when used in places that JSON is expected.

Possible Drawbacks

Anyone relying on json.* constants being strings will need to update their code.

Documentation Notes

I believe the wiki should already match the new behaviour, but just in case:

  • json.null Constant representing a null value in json.
  • json.true Constant representing a true value in json.
  • json.false Constant representing a false value in json.

Release Notes

  • Fixed json.null, json.true, and json.false so that they are real JSON values rather than strings.

This change is Reviewable

@cwisniew cwisniew added this pull request to the merge queue Aug 14, 2023
@cwisniew cwisniew added the bug label Aug 14, 2023
Merged via the queue into RPTools:develop with commit acf29bf Aug 14, 2023
4 checks passed
@kwvanderlinde kwvanderlinde deleted the bugfix/4161-json-constants-are-not-json-values branch August 14, 2023 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

[Bug]: json.null, json.true, json.false are not JSON values
2 participants