Skip to content

Vendor JSON: Serialize unknown objects using reflection#1764

Merged
denrase merged 14 commits into
feat/vendor-json-writer-readerfrom
feat/vendor-json-reflection
Oct 27, 2021
Merged

Vendor JSON: Serialize unknown objects using reflection#1764
denrase merged 14 commits into
feat/vendor-json-writer-readerfrom
feat/vendor-json-reflection

Conversation

@denrase

@denrase denrase commented Oct 13, 2021

Copy link
Copy Markdown
Collaborator

#skip-changelog

📜 Description

Adds JsonReflectionObjectSerializer which is used to serialize objects unknown to the framework to json.

💡 Motivation and Context

  • We are iterating all fields of an object.
  • Transforing classes to a combination of primitives, strings, lists and maps.
  • These structures are used in our serialization and turned into JSON.
  • Transient fields are ignored.
  • Basic cycle detection.
  • Max depth supported, currently set at 100.
  • Private fields are also serialized, I'd need guidance if this is something we want to do. -> Looks like this does not work on objects from other packages.

💚 How did you test it?

  • Please see unit tests.

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • No breaking changes

🔮 Next steps

We need to decide if we want to go this route when serialising classes unknown to the framework.

@denrase denrase self-assigned this Oct 13, 2021
Comment thread sentry/src/main/java/io/sentry/JsonReflectionObjectSerializer.java Outdated
@denrase denrase requested a review from marandaneto October 13, 2021 14:32
@denrase denrase marked this pull request as ready for review October 13, 2021 14:32
Comment thread sentry/src/main/java/io/sentry/JsonSerializer.java

@bruno-garcia bruno-garcia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

would be nice to get a maxDepth setting

Comment thread sentry/src/main/java/io/sentry/JsonReflectionObjectSerializer.java Outdated
Comment thread sentry/src/main/java/io/sentry/JsonReflectionObjectSerializer.java Outdated
Comment thread sentry/src/main/java/io/sentry/JsonObjectSerializer.java Outdated
Comment thread sentry/src/main/java/io/sentry/JsonReflectionObjectSerializer.java
Comment thread sentry/src/main/java/io/sentry/JsonReflectionObjectSerializer.java Outdated
@denrase denrase merged commit fa0127d into feat/vendor-json-writer-reader Oct 27, 2021
@denrase denrase deleted the feat/vendor-json-reflection branch October 27, 2021 09:43
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.

3 participants