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

Add explicit support for floats in JsonWriter. #2130

Merged
merged 1 commit into from Jun 8, 2022

Conversation

Capstan
Copy link
Contributor

@Capstan Capstan commented Jun 8, 2022

This avoids floats being treated as doubles and having an unwarranted level of precision.

Fixes #1127.

@eamonnmcmanus eamonnmcmanus self-assigned this Jun 8, 2022
@eamonnmcmanus eamonnmcmanus self-requested a review June 8, 2022 21:44
Copy link
Member

@eamonnmcmanus eamonnmcmanus left a comment

Choose a reason for hiding this comment

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

Thanks, this looks great.

This avoids floats being treated as doubles and having an unwarranted level of precision.

Fixes google#1127.
@eamonnmcmanus eamonnmcmanus merged commit 96ab171 into google:master Jun 8, 2022
@Capstan Capstan deleted the issues-1127 branch June 9, 2022 00:57
@Marcono1234
Copy link
Collaborator

Could you please also override this new method in JsonTreeWriter? Otherwise users will experience an AssertionError.

@Capstan Capstan restored the issues-1127 branch June 10, 2022 23:10
Capstan added a commit to Capstan/gson that referenced this pull request Jun 10, 2022
Follow-up to comments on google#2130, which introduced a new override which was not overridden by JsonTreeWriter. Also tweaks the doccomments for both float and double varients of JsonWriter.value.

Supplement to the fix for google#1127.
Capstan added a commit to Capstan/gson that referenced this pull request Jun 11, 2022
Follow-up to comments on google#2130, which introduced a new override which was not overridden by `JsonTreeWriter`. Also tweaks the doccomments for `float`, `double` and `Number` variants of `JsonWriter.value`.

Supplement to the fix for google#1127.
eamonnmcmanus pushed a commit that referenced this pull request Jun 21, 2022
Follow-up to comments on #2130, which introduced a new override which was not overridden by `JsonTreeWriter`. Also tweaks the doccomments for `float`, `double` and `Number` variants of `JsonWriter.value`.

Supplement to the fix for #1127.
sgammon added a commit to elide-dev/elide that referenced this pull request Jan 15, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.code.gson:gson-parent](https://togithub.com/google/gson) |
`2.9.0` -> `2.10.1` |
[![age](https://badges.renovateapi.com/packages/maven/com.google.code.gson:gson-parent/2.10.1/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/maven/com.google.code.gson:gson-parent/2.10.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/maven/com.google.code.gson:gson-parent/2.10.1/compatibility-slim/2.9.0)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/maven/com.google.code.gson:gson-parent/2.10.1/confidence-slim/2.9.0)](https://docs.renovatebot.com/merge-confidence/)
|
| [com.google.code.gson:gson](https://togithub.com/google/gson) |
`2.9.0` -> `2.10.1` |
[![age](https://badges.renovateapi.com/packages/maven/com.google.code.gson:gson/2.10.1/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/maven/com.google.code.gson:gson/2.10.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/maven/com.google.code.gson:gson/2.10.1/compatibility-slim/2.9.0)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/maven/com.google.code.gson:gson/2.10.1/confidence-slim/2.9.0)](https://docs.renovatebot.com/merge-confidence/)
|

---

### ⚠ Dependency Lookup Warnings ⚠

Warnings were logged while processing this repo. Please check the
Dependency Dashboard for more information.

---

### Release Notes

<details>
<summary>google/gson</summary>

###
[`v2.10`](https://togithub.com/google/gson/blob/HEAD/CHANGELOG.md#Version-210)

- Support for serializing and deserializing Java records, on Java ≥ 16.
([google/gson#2201)
- Add `JsonArray.asList` and `JsonObject.asMap` view methods
([google/gson#2225)
- Fix `TypeAdapterRuntimeTypeWrapper` not detecting reflective
`TreeTypeAdapter` and `FutureTypeAdapter`
([google/gson#1787)
- Improve `JsonReader.skipValue()`
([google/gson#2062)
- Perform numeric conversion for primitive numeric type adapters
([google/gson#2158)
- Add `Gson.fromJson(..., TypeToken)` overloads
([google/gson#1700)
- Fix changes to `GsonBuilder` affecting existing `Gson` instances
([google/gson#1815)
- Make `JsonElement` conversion methods more consistent and fix javadoc
([google/gson#2178)
- Throw `UnsupportedOperationException` when `JsonWriter.jsonValue` is
not supported
([google/gson#1651)
- Disallow `JsonObject` `Entry.setValue(null)`
([google/gson#2167)
- Fix `TypeAdapter.toJson` throwing AssertionError for custom
IOException
([google/gson#2172)
- Convert null to JsonNull for `JsonArray.set`
([google/gson#2170)
- Fixed nullSafe usage.
([google/gson#1555)
- Validate `TypeToken.getParameterized` arguments
([google/gson#2166)
- Fix [#&#8203;1702](https://togithub.com/google/gson/issues/1702):
Gson.toJson creates CharSequence which does not implement toString
([google/gson#1703)
- Prefer existing adapter for concurrent `Gson.getAdapter` calls
([google/gson#2153)
- Improve `ArrayTypeAdapter` for `Object[]`
([google/gson#1716)
- Improve `AppendableWriter` performance
([google/gson#1706)

###
[`v2.9.1`](https://togithub.com/google/gson/blob/HEAD/CHANGELOG.md#Version-291)

- Make `Object` and `JsonElement` deserialization iterative rather than

recursi[google/gson#1912)
- Added parsing support for enum that has overridden toString() method
([google/gson#1950)
- Removed support for building Gson with Gradle
([google/gson#2081)
- Removed obsolete `codegen` hierarchy
([google/gson#2099)
- Add support for reflection access filter
([google/gson#1905)
- Improve `TypeToken` creation validation
([google/gson#2072)
- Add explicit support for `float` in `JsonWriter`
([google/gson#2130,
[google/gson#2132)
- Fail when parsing invalid local date
([google/gson#2134)

Also many small improvements to javadoc.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/elide-dev/v3).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMDIuMCIsInVwZGF0ZWRJblZlciI6IjM0LjEwMi4wIn0=-->
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.

JsonWriter don't work correctly with float
3 participants