Fix JSON Kotlin Extension Functions #2004
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Fixes our JSON Kotlin extension functions and added tests to ensure our JSON implementation in tests stay accurate.
Details
This PR sloves 3 issues with JSONArray / JSONArray:
org.json:json
forcom.tdunning:json
fixed this.org.json:json
is NOT the same library as Android'sorg.json
namespace!JSONObject.toMap()
Kotlin extension function didn't support nested JSON.org.json:json
for some reason, so swappingcom.tdunning:json
also fixed this issue.This PR is based on some of the attempted work from PR #2003.
Motivation
JSONObject
andJSONArray
are two APIs we use a lot in this SDK. It is important they are working fully and we are testing with the same implementation in tests.Scope
Effects code that uses
JSONObject.toMap()
. And tests that usedorg.json:json
.History
Fun fact, Google rolled their own org.json for Android. They probably did this due to the silly "The Software shall be used for Good, not Evil." line in the orignal org.json licence.
Testing
Unit testing
New JSONObjectEnvTest.kt and JSONObjectExtensionsTest.kt test files were added to cover the behavior changes and ensure test env does not regress.
Manual testing
Tested on an Android 14 emulator ensuring the device tag updates are sent.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is