Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

more robust json generation #110

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

divinity76
Copy link

@divinity76 divinity76 commented Dec 29, 2023

concatenating strings into json is... unreliable.

I think the original code was written that way because definedTags and freeformTags must be object, not array, or be rejected as invalid, and by default json_encode makes them array, not object, the original code fixed it by writing the json manually, the new code fix it with 'definedTags' =>(object)array()

  • the JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE just makes the resulting json easier to read/debug by humans, if ever need be.
  • for example if $displayName is foo"bar then the original code would make the json "displayName": "foo"bar", which is a syntax error, and oci would reject the json as malformed, the new code correctly encodes it into "displayName": "foo\"bar" and the json remains syntactically valid

concatenating strings into json is... unreliable. 

I think the original code was written that way because definedTags and freeformTags *must* be object, not array, or be rejected as invalid, and by default json_encode makes them array, not object, the original code fixed it by writing the json manually, the new code fix it with 'definedTags' =>(object)array()
@divinity76
Copy link
Author

divinity76 commented Jan 1, 2024

this patch is now confirmed to work :D i just got my server yesterday with this patch

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

Successfully merging this pull request may close these issues.

2 participants