Skip to content

fix-37-add-custom-unmarshalJSON-method#48

Closed
devarsh10 wants to merge 1 commit intoappwrite:mainfrom
devarsh10:chore/access-nested-structs
Closed

fix-37-add-custom-unmarshalJSON-method#48
devarsh10 wants to merge 1 commit intoappwrite:mainfrom
devarsh10:chore/access-nested-structs

Conversation

@devarsh10
Copy link

@devarsh10 devarsh10 commented Feb 11, 2026

What does this PR do?

I have added a custom unmarshalJSON method in the preferences.go file. Because earlier, the Go's default decoder used to skip the data field entirely and show nil. Hence, a custom unmarshalJSON method.

Test Plan

  1. First reproduced the issue. Got this error,
User ID: <user-id>
User Email: <email-id>
User Prefs: models.Preferences{data:[]uint8(nil)}
User Prefs: map[string]interface {}{}
  1. Made the changes, added a custom method, and ran the same main file mentioned in the issue
User ID: <uid>
User Email: <mail>
User Prefs: models.Preferences{data:[]uint8{0x7b ... ... ... 0x7d}}
User Prefs: map[string]interface {}{"Hello":"World"}

Related PRs and Issues

Issue it solves: #37

Have you read the Contributing Guidelines on issues?

Yes

Summary by CodeRabbit

  • Chores
    • Enhanced internal preference data handling to improve JSON processing capabilities.

@github-actions
Copy link

This library is auto-generated by the Appwrite SDK Generator, and does not accept pull requests directly. To learn more about how you can help us improve this SDK, please check the contributing guide.

@github-actions github-actions bot closed this Feb 11, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

A new public method UnmarshalJSON is added to the Preferences type in models/preferences.go. The method accepts a byte slice containing JSON data, copies it into the struct's data field, and returns nil. This enables the Preferences struct to implement the standard JSON unmarshalling hook while preserving raw JSON bytes for subsequent processing by the existing Decode method.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Successfully merging this pull request may close these issues.

1 participant