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 the Incorrectly generated attributes for toJsonString of Tree #131

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

humdrum
Copy link
Contributor

@humdrum humdrum commented Dec 19, 2023

What this PR does / why we need it:

  • Fix the Incorrectly generated attributes for toJsonString of Tree

The attributes of Tree node are contained as json String.
When initialize the JSONTreeNode, the json String converted to dictionary by toJSONObject in String+Extension.

var toJSONObject: Any {
if let data = self.data(using: .utf8) {
return (try? JSONSerialization.jsonObject(with: data, options: [.fragmentsAllowed])) ?? self
}
return self
}

The "jsonObject" that "JSONSerialization.jsonObject()" creates contains foundation types. (NSNumber, NSString...)
Since "jsonObject" isn't Encodable, they can't converted to string by old logic.
So I added JSONSerialization.data() to convert them to string.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

  • Added relevant tests or not required
  • Didn't break anything

@humdrum humdrum added the bug 🐞 Something isn't working label Dec 19, 2023
@humdrum humdrum requested a review from myupage December 19, 2023 11:38
@humdrum humdrum self-assigned this Dec 19, 2023
Copy link

codecov bot commented Dec 19, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ca1fbc0) 43.07% compared to head (d18643f) 43.31%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #131      +/-   ##
==========================================
+ Coverage   43.07%   43.31%   +0.23%     
==========================================
  Files         104      104              
  Lines       22958    22972      +14     
==========================================
+ Hits         9890     9951      +61     
+ Misses      13068    13021      -47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@myupage myupage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great

@humdrum humdrum merged commit b753c3e into main Dec 19, 2023
3 checks passed
@humdrum humdrum deleted the fix_tree_tojson_attr branch December 19, 2023 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants