Skip to content

Add fromJsonElement method to generated models#1148

Merged
fuzzybinary merged 2 commits into
developfrom
jward/from-json-element-generator
Nov 21, 2022
Merged

Add fromJsonElement method to generated models#1148
fuzzybinary merged 2 commits into
developfrom
jward/from-json-element-generator

Conversation

@fuzzybinary

Copy link
Copy Markdown
Member

What does this PR do?

Add a method to the model generator to change the current fromJson method to parse the JSON, then pass the result to fromJsonElement. Additionally, change all of the methods that used fromJson for nested objects to instead use fromJsonElement for efficiency.

Motivation

This should be more for nested models, and makes it easier for Flutter to build the models from the Maps we'll get back from the method channel. Otherwise, Flutter will need to convert the object from a map to a JSON string, then ask the model to parse it back out.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@fuzzybinary
fuzzybinary requested a review from a team as a code owner November 17, 2022 22:39
@xgouchet xgouchet added the size-medium This PR is medium sized label Nov 17, 2022
This should be more for nested models, and makes it easier for Flutter to build the models from the Maps we'll get back from the method channel.
@fuzzybinary
fuzzybinary force-pushed the jward/from-json-element-generator branch from 29d1f2d to ad2e85f Compare November 18, 2022 02:09
@codecov-commenter

codecov-commenter commented Nov 18, 2022

Copy link
Copy Markdown

Codecov Report

Merging #1148 (2060705) into develop (8ddbd15) will decrease coverage by 0.10%.
The diff coverage is 80.37%.

@@             Coverage Diff             @@
##           develop    #1148      +/-   ##
===========================================
- Coverage    83.11%   83.01%   -0.10%     
===========================================
  Files          275      275              
  Lines         9528     9683     +155     
  Branches      1556     1568      +12     
===========================================
+ Hits          7919     8038     +119     
- Misses        1160     1188      +28     
- Partials       449      457       +8     
Impacted Files Coverage Δ
...droid/log/internal/logger/ConditionalLogHandler.kt 33.33% <0.00%> (-66.67%) ⬇️
...og/android/log/internal/logger/LogcatLogHandler.kt 78.85% <0.00%> (-16.50%) ⬇️
.../main/kotlin/com/datadog/android/rum/RumMonitor.kt 78.26% <ø> (ø)
.../datadog/android/log/internal/logger/LogHandler.kt 77.78% <75.00%> (-2.22%) ⬇️
...atadog/android/log/internal/domain/LogGenerator.kt 93.15% <81.25%> (-5.87%) ⬇️
...g/android/log/internal/logger/DatadogLogHandler.kt 91.84% <88.46%> (-3.82%) ⬇️
.../main/kotlin/com/datadog/android/_InternalProxy.kt 88.89% <100.00%> (+1.39%) ⬆️
...atadog/android/core/configuration/Configuration.kt 98.78% <100.00%> (+0.02%) ⬆️
...n/com/datadog/android/core/internal/CoreFeature.kt 91.74% <100.00%> (+0.03%) ⬆️
...adog/android/error/internal/CrashReportsFeature.kt 100.00% <100.00%> (ø)
... and 14 more

@xgouchet xgouchet added the size-large This PR is large sized label Nov 18, 2022
Also clean up to use .asJsonObject and catch IllegalStateExceptions during String parse.
@fuzzybinary
fuzzybinary force-pushed the jward/from-json-element-generator branch from 664a0b5 to 2060705 Compare November 18, 2022 15:36
@fuzzybinary
fuzzybinary requested a review from 0xnm November 19, 2022 02:10
@fuzzybinary
fuzzybinary merged commit f6e371d into develop Nov 21, 2022
@fuzzybinary
fuzzybinary deleted the jward/from-json-element-generator branch November 21, 2022 13:27
@xgouchet xgouchet added this to the 1.16.0 milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-large This PR is large sized size-medium This PR is medium sized

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants