Showing preview only (2,226K chars total). Download the full file or copy to clipboard to get everything.
Repository: google/gson
Branch: main
Commit: 1fa9b7a0a994
Files: 305
Total size: 2.1 MB
Directory structure:
gitextract_4tdusv9e/
├── .git-blame-ignore-revs
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ ├── config.yml
│ │ └── feature_request.md
│ ├── dependabot.yml
│ ├── pull_request_template.md
│ └── workflows/
│ ├── build.yml
│ ├── check-android-compatibility.yml
│ ├── check-api-compatibility.yml
│ ├── cifuzz.yml
│ ├── codeql-analysis.yml
│ └── scorecard.yml
├── .gitignore
├── .mvn/
│ └── jvm.config
├── CHANGELOG.md
├── GsonDesignDocument.md
├── LICENSE
├── README.md
├── ReleaseProcess.md
├── Troubleshooting.md
├── UserGuide.md
├── extras/
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ ├── main/
│ │ └── java/
│ │ └── com/
│ │ └── google/
│ │ └── gson/
│ │ ├── extras/
│ │ │ └── examples/
│ │ │ └── rawcollections/
│ │ │ └── RawCollectionsExample.java
│ │ ├── interceptors/
│ │ │ ├── Intercept.java
│ │ │ ├── InterceptorFactory.java
│ │ │ └── JsonPostDeserializer.java
│ │ └── typeadapters/
│ │ ├── PostConstructAdapterFactory.java
│ │ ├── RuntimeTypeAdapterFactory.java
│ │ └── UtcDateTypeAdapter.java
│ └── test/
│ └── java/
│ └── com/
│ └── google/
│ └── gson/
│ ├── interceptors/
│ │ └── InterceptorTest.java
│ └── typeadapters/
│ ├── PostConstructAdapterFactoryTest.java
│ ├── RuntimeTypeAdapterFactoryTest.java
│ └── UtcDateTypeAdapterTest.java
├── gson/
│ ├── LICENSE
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ ├── main/
│ │ ├── java/
│ │ │ ├── com/
│ │ │ │ └── google/
│ │ │ │ └── gson/
│ │ │ │ ├── ExclusionStrategy.java
│ │ │ │ ├── FieldAttributes.java
│ │ │ │ ├── FieldNamingPolicy.java
│ │ │ │ ├── FieldNamingStrategy.java
│ │ │ │ ├── FormattingStyle.java
│ │ │ │ ├── Gson.java
│ │ │ │ ├── GsonBuilder.java
│ │ │ │ ├── InstanceCreator.java
│ │ │ │ ├── JsonArray.java
│ │ │ │ ├── JsonDeserializationContext.java
│ │ │ │ ├── JsonDeserializer.java
│ │ │ │ ├── JsonElement.java
│ │ │ │ ├── JsonIOException.java
│ │ │ │ ├── JsonNull.java
│ │ │ │ ├── JsonObject.java
│ │ │ │ ├── JsonParseException.java
│ │ │ │ ├── JsonParser.java
│ │ │ │ ├── JsonPrimitive.java
│ │ │ │ ├── JsonSerializationContext.java
│ │ │ │ ├── JsonSerializer.java
│ │ │ │ ├── JsonStreamParser.java
│ │ │ │ ├── JsonSyntaxException.java
│ │ │ │ ├── LongSerializationPolicy.java
│ │ │ │ ├── ReflectionAccessFilter.java
│ │ │ │ ├── Strictness.java
│ │ │ │ ├── ToNumberPolicy.java
│ │ │ │ ├── ToNumberStrategy.java
│ │ │ │ ├── TypeAdapter.java
│ │ │ │ ├── TypeAdapterFactory.java
│ │ │ │ ├── annotations/
│ │ │ │ │ ├── Expose.java
│ │ │ │ │ ├── JsonAdapter.java
│ │ │ │ │ ├── SerializedName.java
│ │ │ │ │ ├── Since.java
│ │ │ │ │ ├── Until.java
│ │ │ │ │ └── package-info.java
│ │ │ │ ├── internal/
│ │ │ │ │ ├── ConstructorConstructor.java
│ │ │ │ │ ├── Excluder.java
│ │ │ │ │ ├── GsonTypes.java
│ │ │ │ │ ├── JavaVersion.java
│ │ │ │ │ ├── JsonReaderInternalAccess.java
│ │ │ │ │ ├── LazilyParsedNumber.java
│ │ │ │ │ ├── LinkedTreeMap.java
│ │ │ │ │ ├── NonNullElementWrapperList.java
│ │ │ │ │ ├── NumberLimits.java
│ │ │ │ │ ├── ObjectConstructor.java
│ │ │ │ │ ├── PreJava9DateFormatProvider.java
│ │ │ │ │ ├── Primitives.java
│ │ │ │ │ ├── ReflectionAccessFilterHelper.java
│ │ │ │ │ ├── Streams.java
│ │ │ │ │ ├── TroubleshootingGuide.java
│ │ │ │ │ ├── UnsafeAllocator.java
│ │ │ │ │ ├── bind/
│ │ │ │ │ │ ├── ArrayTypeAdapter.java
│ │ │ │ │ │ ├── CollectionTypeAdapterFactory.java
│ │ │ │ │ │ ├── DefaultDateTypeAdapter.java
│ │ │ │ │ │ ├── EnumTypeAdapter.java
│ │ │ │ │ │ ├── IgnoreJRERequirement.java
│ │ │ │ │ │ ├── JavaTimeTypeAdapters.java
│ │ │ │ │ │ ├── JsonAdapterAnnotationTypeAdapterFactory.java
│ │ │ │ │ │ ├── JsonElementTypeAdapter.java
│ │ │ │ │ │ ├── JsonTreeReader.java
│ │ │ │ │ │ ├── JsonTreeWriter.java
│ │ │ │ │ │ ├── MapTypeAdapterFactory.java
│ │ │ │ │ │ ├── NumberTypeAdapter.java
│ │ │ │ │ │ ├── ObjectTypeAdapter.java
│ │ │ │ │ │ ├── ReflectiveTypeAdapterFactory.java
│ │ │ │ │ │ ├── SerializationDelegatingTypeAdapter.java
│ │ │ │ │ │ ├── TreeTypeAdapter.java
│ │ │ │ │ │ ├── TypeAdapterRuntimeTypeWrapper.java
│ │ │ │ │ │ ├── TypeAdapters.java
│ │ │ │ │ │ └── util/
│ │ │ │ │ │ └── ISO8601Utils.java
│ │ │ │ │ ├── package-info.java
│ │ │ │ │ ├── reflect/
│ │ │ │ │ │ └── ReflectionHelper.java
│ │ │ │ │ └── sql/
│ │ │ │ │ ├── SqlDateTypeAdapter.java
│ │ │ │ │ ├── SqlTimeTypeAdapter.java
│ │ │ │ │ ├── SqlTimestampTypeAdapter.java
│ │ │ │ │ └── SqlTypesSupport.java
│ │ │ │ ├── package-info.java
│ │ │ │ ├── reflect/
│ │ │ │ │ ├── TypeToken.java
│ │ │ │ │ └── package-info.java
│ │ │ │ └── stream/
│ │ │ │ ├── JsonReader.java
│ │ │ │ ├── JsonScope.java
│ │ │ │ ├── JsonToken.java
│ │ │ │ ├── JsonWriter.java
│ │ │ │ ├── MalformedJsonException.java
│ │ │ │ └── package-info.java
│ │ │ └── module-info.java
│ │ ├── java-templates/
│ │ │ └── com/
│ │ │ └── google/
│ │ │ └── gson/
│ │ │ └── internal/
│ │ │ └── GsonBuildConfig.java
│ │ └── resources/
│ │ └── META-INF/
│ │ └── proguard/
│ │ └── gson.pro
│ └── test/
│ ├── java/
│ │ └── com/
│ │ └── google/
│ │ └── gson/
│ │ ├── CommentsTest.java
│ │ ├── DefaultInetAddressTypeAdapterTest.java
│ │ ├── DefaultMapJsonSerializerTest.java
│ │ ├── ExposeAnnotationExclusionStrategyTest.java
│ │ ├── FieldAttributesTest.java
│ │ ├── FieldNamingPolicyTest.java
│ │ ├── GenericArrayTypeTest.java
│ │ ├── GsonBuilderTest.java
│ │ ├── GsonTest.java
│ │ ├── GsonTypeAdapterTest.java
│ │ ├── InnerClassExclusionStrategyTest.java
│ │ ├── JavaSerializationTest.java
│ │ ├── JsonArrayAsListSuiteTest.java
│ │ ├── JsonArrayAsListTest.java
│ │ ├── JsonArrayTest.java
│ │ ├── JsonNullTest.java
│ │ ├── JsonObjectAsMapSuiteTest.java
│ │ ├── JsonObjectAsMapTest.java
│ │ ├── JsonObjectTest.java
│ │ ├── JsonParserParameterizedTest.java
│ │ ├── JsonParserTest.java
│ │ ├── JsonPrimitiveTest.java
│ │ ├── JsonStreamParserTest.java
│ │ ├── LongSerializationPolicyTest.java
│ │ ├── MixedStreamTest.java
│ │ ├── ObjectTypeAdapterParameterizedTest.java
│ │ ├── ObjectTypeAdapterTest.java
│ │ ├── OverrideCoreTypeAdaptersTest.java
│ │ ├── ParameterizedTypeFixtures.java
│ │ ├── ParameterizedTypeTest.java
│ │ ├── PrimitiveTypeAdapter.java
│ │ ├── SubsetTest.java
│ │ ├── ToNumberPolicyTest.java
│ │ ├── TypeAdapterTest.java
│ │ ├── VersionExclusionStrategyTest.java
│ │ ├── common/
│ │ │ ├── MoreAsserts.java
│ │ │ └── TestTypes.java
│ │ ├── functional/
│ │ │ ├── ArrayTest.java
│ │ │ ├── CircularReferenceTest.java
│ │ │ ├── CollectionTest.java
│ │ │ ├── ConcurrencyTest.java
│ │ │ ├── CustomDeserializerTest.java
│ │ │ ├── CustomSerializerTest.java
│ │ │ ├── CustomTypeAdaptersTest.java
│ │ │ ├── DefaultTypeAdaptersTest.java
│ │ │ ├── DelegateTypeAdapterTest.java
│ │ │ ├── EnumTest.java
│ │ │ ├── EnumWithObfuscatedTest.java
│ │ │ ├── EscapingTest.java
│ │ │ ├── ExclusionStrategyFunctionalTest.java
│ │ │ ├── ExposeFieldsTest.java
│ │ │ ├── FieldExclusionTest.java
│ │ │ ├── FieldNamingTest.java
│ │ │ ├── FormattingStyleTest.java
│ │ │ ├── GsonVersionDiagnosticsTest.java
│ │ │ ├── InheritanceTest.java
│ │ │ ├── InstanceCreatorTest.java
│ │ │ ├── InterfaceTest.java
│ │ │ ├── InternationalizationTest.java
│ │ │ ├── Java17RecordTest.java
│ │ │ ├── JavaUtilConcurrentAtomicTest.java
│ │ │ ├── JavaUtilTest.java
│ │ │ ├── JsonAdapterAnnotationOnClassesTest.java
│ │ │ ├── JsonAdapterAnnotationOnFieldsTest.java
│ │ │ ├── JsonAdapterSerializerDeserializerTest.java
│ │ │ ├── JsonParserTest.java
│ │ │ ├── JsonTreeTest.java
│ │ │ ├── LeniencyTest.java
│ │ │ ├── MapAsArrayTypeAdapterTest.java
│ │ │ ├── MapTest.java
│ │ │ ├── MoreSpecificTypeSerializationTest.java
│ │ │ ├── NamingPolicyTest.java
│ │ │ ├── NullObjectAndFieldTest.java
│ │ │ ├── NumberLimitsTest.java
│ │ │ ├── ObjectTest.java
│ │ │ ├── ParameterizedTypesTest.java
│ │ │ ├── PrettyPrintingTest.java
│ │ │ ├── PrimitiveCharacterTest.java
│ │ │ ├── PrimitiveTest.java
│ │ │ ├── PrintFormattingTest.java
│ │ │ ├── RawSerializationTest.java
│ │ │ ├── ReadersWritersTest.java
│ │ │ ├── ReflectionAccessFilterTest.java
│ │ │ ├── ReflectionAccessTest.java
│ │ │ ├── ReusedTypeVariablesFullyResolveTest.java
│ │ │ ├── RuntimeTypeAdapterFactoryFunctionalTest.java
│ │ │ ├── SecurityTest.java
│ │ │ ├── SerializedNameTest.java
│ │ │ ├── StreamingTypeAdaptersTest.java
│ │ │ ├── StringTest.java
│ │ │ ├── ToNumberPolicyFunctionalTest.java
│ │ │ ├── TreeTypeAdaptersTest.java
│ │ │ ├── TypeAdapterPrecedenceTest.java
│ │ │ ├── TypeAdapterRuntimeTypeWrapperTest.java
│ │ │ ├── TypeHierarchyAdapterTest.java
│ │ │ ├── TypeVariableTest.java
│ │ │ ├── UncategorizedTest.java
│ │ │ └── VersioningTest.java
│ │ ├── integration/
│ │ │ └── OSGiManifestIT.java
│ │ ├── internal/
│ │ │ ├── ConstructorConstructorTest.java
│ │ │ ├── GsonBuildConfigTest.java
│ │ │ ├── GsonTypesTest.java
│ │ │ ├── JavaVersionTest.java
│ │ │ ├── LazilyParsedNumberTest.java
│ │ │ ├── LinkedTreeMapSuiteTest.java
│ │ │ ├── LinkedTreeMapTest.java
│ │ │ ├── StreamsTest.java
│ │ │ ├── UnsafeAllocatorInstantiationTest.java
│ │ │ ├── bind/
│ │ │ │ ├── DefaultDateTypeAdapterTest.java
│ │ │ │ ├── Java17ReflectiveTypeAdapterFactoryTest.java
│ │ │ │ ├── JsonElementReaderTest.java
│ │ │ │ ├── JsonTreeReaderTest.java
│ │ │ │ ├── JsonTreeWriterTest.java
│ │ │ │ ├── RecursiveTypesResolveTest.java
│ │ │ │ └── util/
│ │ │ │ └── ISO8601UtilsTest.java
│ │ │ ├── reflect/
│ │ │ │ └── Java17ReflectionHelperTest.java
│ │ │ └── sql/
│ │ │ ├── SqlTypesGsonTest.java
│ │ │ └── SqlTypesSupportTest.java
│ │ ├── metrics/
│ │ │ └── PerformanceTest.java
│ │ ├── reflect/
│ │ │ └── TypeTokenTest.java
│ │ └── stream/
│ │ ├── JsonReaderPathTest.java
│ │ ├── JsonReaderTest.java
│ │ └── JsonWriterTest.java
│ └── resources/
│ └── testcases-proguard.conf
├── metrics/
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ └── main/
│ └── java/
│ └── com/
│ └── google/
│ └── gson/
│ └── metrics/
│ ├── BagOfPrimitives.java
│ ├── BagOfPrimitivesDeserializationBenchmark.java
│ ├── CollectionsDeserializationBenchmark.java
│ ├── NonUploadingCaliperRunner.java
│ ├── ParseBenchmark.java
│ └── SerializationBenchmark.java
├── pom.xml
├── proto/
│ ├── .gitignore
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ ├── main/
│ │ └── java/
│ │ └── com/
│ │ └── google/
│ │ └── gson/
│ │ └── protobuf/
│ │ └── ProtoTypeAdapter.java
│ └── test/
│ ├── java/
│ │ └── com/
│ │ └── google/
│ │ └── gson/
│ │ └── protobuf/
│ │ └── functional/
│ │ ├── ProtosWithAnnotationsAndJsonNamesTest.java
│ │ ├── ProtosWithAnnotationsTest.java
│ │ ├── ProtosWithComplexAndRepeatedFieldsTest.java
│ │ └── ProtosWithPrimitiveTypesTest.java
│ └── protobuf/
│ ├── annotations.proto
│ └── bag.proto
├── test-graal-native-image/
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ └── test/
│ ├── java/
│ │ └── com/
│ │ └── google/
│ │ └── gson/
│ │ └── native_test/
│ │ ├── Java17RecordReflectionTest.java
│ │ └── ReflectionTest.java
│ └── resources/
│ └── META-INF/
│ └── native-image/
│ └── reflect-config.json
├── test-jpms/
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ ├── main/
│ │ └── java/
│ │ └── module-info.java
│ └── test/
│ └── java/
│ ├── com/
│ │ └── google/
│ │ └── gson/
│ │ └── jpms_test/
│ │ ├── ExportedPackagesTest.java
│ │ ├── ModuleTest.java
│ │ ├── ReflectionInaccessibleTest.java
│ │ └── opened/
│ │ └── ReflectionTest.java
│ └── module-info.java
└── test-shrinker/
├── README.md
├── common.pro
├── pom.xml
├── proguard.pro
├── r8.pro
└── src/
├── main/
│ └── java/
│ └── com/
│ └── example/
│ ├── ClassWithAdapter.java
│ ├── ClassWithExposeAnnotation.java
│ ├── ClassWithHasArgsConstructor.java
│ ├── ClassWithJsonAdapterAnnotation.java
│ ├── ClassWithNamedFields.java
│ ├── ClassWithNoArgsConstructor.java
│ ├── ClassWithSerializedName.java
│ ├── ClassWithUnreferencedHasArgsConstructor.java
│ ├── ClassWithUnreferencedNoArgsConstructor.java
│ ├── ClassWithVersionAnnotations.java
│ ├── EnumClass.java
│ ├── EnumClassWithSerializedName.java
│ ├── GenericClasses.java
│ ├── InterfaceWithImplementation.java
│ ├── Main.java
│ ├── NoSerializedNameMain.java
│ ├── TestExecutor.java
│ └── UnusedClass.java
└── test/
└── java/
└── com/
└── google/
└── gson/
└── it/
└── ShrinkingIT.java
================================================
FILE CONTENTS
================================================
================================================
FILE: .git-blame-ignore-revs
================================================
# Ignore commit which reformatted code
2c94c757a6a9426cc2fe47bc1c63f69e7c73b7b4
# Ignore commit which changed line endings consistently to LF
c2a0e4634a2100494159add78db2ee06f5eb9be6
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Report a Gson bug. Please have a look at the troubleshooting guide (Troubleshooting.md) first.
title: ''
labels: bug
assignees: ''
---
# Gson version
<!-- Gson version you are using, for example '2.8.8' -->
# Java / Android version
<!-- Version of the Java or Android platform on which the bug occurred -->
# Used tools
<!-- List relevant build tools and plugins with version number here which might affect Gson -->
- [ ] Maven; version:
- [ ] Gradle; version:
- [ ] ProGuard (attach the configuration file please); version:
- [ ] ...
# Description
<!-- Describe the bug you experienced -->
## Expected behavior
<!-- What behavior did you expect? -->
## Actual behavior
<!-- What happened instead? -->
# Reproduction steps
<!-- Provide exact reproduction steps for reproducing the bug -->
<!-- Provide a short code snippet or link to a demo project -->
1. ...
2. ...
# Exception stack trace
<!-- In case an exception occurred, paste the COMPLETE exception stack trace in the code block below or attach it as file -->
```
```
================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
contact_links:
- name: Usage question
url: https://stackoverflow.com/questions/tagged/gson
about: Ask usage questions on StackOverflow.
- name: Questions, ideas, tips & tricks, ...
url: https://github.com/google/gson/discussions
about: Share information in GitHub Discussions.
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Request a feature. ⚠️ Gson is in maintenance mode; large feature requests might be rejected.
title: ''
labels: enhancement
assignees: ''
---
# Problem solved by the feature
<!-- Describe which problem the requested feature solves -->
# Feature description
<!-- Describe the feature -->
# Alternatives / workarounds
<!-- Describe alternatives or workarounds in case you are aware of any -->
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "monthly"
cooldown:
default-days: 14
groups:
# Name is used for branch name and pull request title
maven:
patterns:
# Create a single pull request for all dependencies and plugins
- "*"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
cooldown:
default-days: 14
groups:
# Name is used for branch name and pull request title
github-actions:
patterns:
# Create a single pull request for all actions
- "*"
================================================
FILE: .github/pull_request_template.md
================================================
<!--
Thank you for your contribution!
Please see the contributing guide: https://github.com/google/.github/blob/master/CONTRIBUTING.md
Keep in mind that Gson is in maintenance mode. If you want to add a new feature, please first search for existing GitHub issues, or create a new one to discuss the feature and get feedback.
-->
### Purpose
<!-- Describe the purpose of this pull request, for example which new feature it adds or which bug it fixes -->
<!-- If this pull request closes a GitHub issue, please write "Closes #<issue>", for example "Closes #123" -->
### Description
<!-- If necessary provide more information, for example relevant implementation details or corner cases which are not covered yet -->
<!-- If there are related issues or pull requests, link to them by referencing their number, for example "pull request #123" -->
### Checklist
<!-- The following checklist is mainly intended for yourself to verify that you did not miss anything -->
- [ ] New code follows the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html)\
This is automatically checked by `mvn verify`, but can also be checked on its own using `mvn spotless:check`.\
Style violations can be fixed using `mvn spotless:apply`; this can be done in a separate commit to verify that it did not cause undesired changes.
- [ ] If necessary, new public API validates arguments, for example rejects `null`
- [ ] New public API has Javadoc
- [ ] Javadoc uses `@since $next-version$`
(`$next-version$` is a special placeholder which is automatically replaced during release)
- [ ] If necessary, new unit tests have been added
- [ ] Assertions in unit tests use [Truth](https://truth.dev/), see existing tests
- [ ] No JUnit 3 features are used (such as extending class `TestCase`)
- [ ] If this pull request fixes a bug, a new test was added for a situation which failed previously and is now fixed
- [ ] `mvn clean verify javadoc:jar` passes without errors
================================================
FILE: .github/workflows/build.yml
================================================
name: Build
on:
push:
branches-ignore:
# Ignore Dependabot branches because it will also open a pull request, which would cause the
# workflow to redundantly run twice
- dependabot/**
pull_request:
permissions:
contents: read # to fetch code (actions/checkout)
env:
# Common Maven arguments
MAVEN_ARGS: --show-version --batch-mode --no-transfer-progress
jobs:
build:
name: "Build on JDK ${{ matrix.java }}"
strategy:
matrix:
java: [ 17, 21 ]
include:
# Custom JDK 11 configuration because some of the plugins and test dependencies don't support it anymore,
# but it is important to still test with a JDK version without Record classes
- java: 11
# Disable Enforcer check which (intentionally) prevents using JDK 11 for building
# Exclude 'test-graal-native-image' module because JUnit 6 requires >= Java 17
# Exclude 'proto' module because protobuf-maven-plugin requires >= Java 17
extra-mvn-args: -Denforcer.fail=false --projects '!test-graal-native-image,!proto'
- java: 25
# Disable Enforcer check which (intentionally) prevents using JDK 25 for building
# Exclude 'test-shrinker' because ProGuard does not support JDK 25 yet, see
# https://github.com/Guardsquare/proguard/issues/481 and https://github.com/Guardsquare/proguard/issues/473
# TODO: Once ProGuard supports JDK 25, also remove the corresponding 'JDK25' profile in `gson/pom.xml`
extra-mvn-args: -Denforcer.fail=false --projects '!test-shrinker'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "Set up JDK ${{ matrix.java }}"
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Build with Maven
# This also runs javadoc:jar to detect any issues with the Javadoc generated during release
run: mvn verify javadoc:jar ${{ matrix.extra-mvn-args || '' }}
# Build a subset of the Gson API, see also https://github.com/google/gson/pull/2946
build-gson-subset:
name: Build Gson subset
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: 'temurin'
java-version: 21
cache: 'maven'
- name: Build with Maven
run: mvn clean test --projects gson --activate-profiles gson-subset
native-image-test:
name: "GraalVM Native Image test (JDK ${{ matrix.java }})"
strategy:
matrix:
java: [ 21 ]
include:
- java: 25
# Disable Enforcer check which (intentionally) prevents using JDK 25 for building
# TODO: Remove this once JDK 25 is fully supported for building Gson
extra-mvn-args: -Denforcer.fail=false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "Set up GraalVM"
uses: graalvm/setup-graalvm@54b4f5a65c1a84b2fdfdc2078fe43df32819e4b1 # v1.4.5
with:
java-version: ${{ matrix.java }}
distribution: 'graalvm'
# According to documentation in graalvm/setup-graalvm this is used to avoid rate-limiting issues
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
- name: Build and run tests
# Only run tests in `test-graal-native-image` (and implicitly build and run tests in `gson`),
# everything else is covered already by regular build job above
run: mvn test --activate-profiles native-image-test --projects test-graal-native-image --also-make ${{ matrix.extra-mvn-args || '' }}
verify-reproducible-build:
name: "Verify reproducible build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: 'temurin'
java-version: 17
cache: 'maven'
- name: "Verify no plugin issues"
run: mvn artifact:check-buildplan --projects '!metrics,!test-graal-native-image,!test-jpms,!test-shrinker'
- name: "Verify reproducible build"
# See https://maven.apache.org/guides/mini/guide-reproducible-builds.html#how-to-test-my-maven-build-reproducibility
run: |
mvn clean install -Dmaven.test.skip --projects '!metrics,!test-graal-native-image,!test-jpms,!test-shrinker'
# Run with `-Dbuildinfo.attach=false`; otherwise `artifact:compare` fails because it creates a `.buildinfo` file which
# erroneously references the existing `.buildinfo` file (respectively because it is overwriting it, a file with size 0)
# See https://issues.apache.org/jira/browse/MARTIFACT-57
mvn clean verify artifact:compare -Dmaven.test.skip --projects '!metrics,!test-graal-native-image,!test-jpms,!test-shrinker' -Dbuildinfo.attach=false
================================================
FILE: .github/workflows/check-android-compatibility.yml
================================================
# For security reasons this is a separate GitHub workflow, see https://github.com/google/gson/issues/2429#issuecomment-1622522842
# Once https://github.com/mojohaus/animal-sniffer/issues/252 or https://github.com/mojohaus/animal-sniffer/pull/253
# are resolved, can consider adjusting pom.xml to include this as part of normal Maven build
name: Check Android compatibility
on:
push:
branches-ignore:
# Ignore Dependabot branches because it will also open a pull request, which would cause the
# workflow to redundantly run twice
- dependabot/**
pull_request:
permissions:
contents: read # to fetch code (actions/checkout)
env:
# Common Maven arguments
MAVEN_ARGS: --show-version --batch-mode --no-transfer-progress
jobs:
check-android-compatibility:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Check Android compatibility
run: |
mvn compile animal-sniffer:check@check-android-compatibility -Dmaven.test.skip --projects '!metrics,!test-graal-native-image,!test-jpms,!test-shrinker'
================================================
FILE: .github/workflows/check-api-compatibility.yml
================================================
# This workflow makes sure that a pull request does not make any incompatible changes
# to the public API of Gson
name: Check API compatibility
on: pull_request
permissions:
contents: read # to fetch code (actions/checkout)
env:
# Common Maven arguments
MAVEN_ARGS: --show-version --batch-mode --no-transfer-progress
jobs:
check-api-compatibility:
runs-on: ubuntu-latest
# This setup tries to determine API incompatibility only for the changes introduced by the
# pull request. It does this by first checking out the 'old' version and installing it into
# the local Maven repository before then using japicmp to compare it to the current changes.
#
# Alternatively it would also be possible to compare against the last release version instead.
#
# Both approaches have their advantages and disadvantages, see description of
# https://github.com/google/gson/pull/2692 for details.
steps:
- name: Check out old version
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.base.sha }}
path: 'gson-old-japicmp'
- name: Set up JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Build old version
run: |
cd gson-old-japicmp
# Set dummy version
mvn org.codehaus.mojo:versions-maven-plugin:2.16.2:set "-DnewVersion=0.0.0-JAPICMP-OLD"
# Install artifacts with dummy version in local repository; used later by Maven plugin for comparison
mvn install -Dmaven.test.skip --projects '!metrics,!test-graal-native-image,!test-jpms,!test-shrinker'
- name: Check out new version
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check API compatibility
id: check-compatibility
run: |
mvn package japicmp:cmp --fail-at-end -Dmaven.test.skip --projects '!extras,!metrics,!test-graal-native-image,!test-jpms,!test-shrinker'
- name: Upload API differences artifacts
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
# Run on workflow success (in that case differences report might include added methods and classes)
# or when API compatibility check failed
if: success() || ( failure() && steps.check-compatibility.outcome == 'failure' )
with:
name: api-differences
path: |
**/japicmp/default-cli.html
**/japicmp/default-cli.diff
# Plugin should always have created report files (though they might be empty)
if-no-files-found: error
================================================
FILE: .github/workflows/cifuzz.yml
================================================
name: CIFuzz
on: [pull_request]
permissions: {}
jobs:
Fuzzing:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Build Fuzzers
id: build
# Cannot be pinned to commit because there are no releases, see https://github.com/google/oss-fuzz/issues/6836
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'gson'
dry-run: false
language: jvm
- name: Run Fuzzers
# Cannot be pinned to commit because there are no releases, see https://github.com/google/oss-fuzz/issues/6836
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'gson'
fuzz-seconds: 600
dry-run: false
output-sarif: true
- name: Upload Crash
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts
- name: Upload Sarif
if: always() && steps.build.outcome == 'success'
uses: github/codeql-action/upload-sarif@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
with:
# Path to SARIF file relative to the root of the repository
sarif_file: cifuzz-sarif/results.sarif
checkout_path: cifuzz-sarif
================================================
FILE: .github/workflows/codeql-analysis.yml
================================================
# Based on default config generated by GitHub, see also https://github.com/github/codeql-action
name: "CodeQL"
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
# Run every Monday at 16:10
- cron: '10 16 * * 1'
permissions:
contents: read # to fetch code (actions/checkout)
env:
# Common Maven arguments
MAVEN_ARGS: --show-version --batch-mode --no-transfer-progress
jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
permissions:
security-events: write
strategy:
fail-fast: false
matrix:
include:
- language: java
build-mode: manual
# GitHub Actions
- language: actions
build-mode: none
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up JDK
if: ${{ matrix.language == 'java' }}
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
# Initializes the CodeQL tools for scanning
- name: Initialize CodeQL
uses: github/codeql-action/init@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# Run all security queries and maintainability and reliability queries
queries: +security-and-quality
# Only compile main sources, but ignore test sources because findings for them might not
# be that relevant (though GitHub security view also allows filtering by source type)
# Can replace this with github/codeql-action/autobuild action to run complete build
- name: Compile sources (Java)
if: ${{ matrix.language == 'java' }}
run: |
mvn compile
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
with:
category: "/language:${{ matrix.language }}"
================================================
FILE: .github/workflows/scorecard.yml
================================================
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.
name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '18 22 * * 3'
push:
branches: [ "main" ]
# Declare default permissions as read only.
permissions: read-all
jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
# `publish_results: true` only works when run from the default branch. conditional can be removed if disabled.
if: github.event.repository.default_branch == github.ref_name || github.event_name == 'pull_request'
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
# Uncomment the permissions below if installing in a private repository.
# contents: read
# actions: read
steps:
- name: "Checkout code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecard on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true
# (Optional) Uncomment file_mode if you have a .gitattributes with files marked export-ignore
# file_mode: git
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
with:
sarif_file: results.sarif
================================================
FILE: .gitignore
================================================
.classpath
.project
.settings
eclipsebin
target
*/target
pom.xml.*
release.properties
.idea
*.iml
*.ipr
*.iws
classes
.gradle
local.properties
build
.DS_Store
================================================
FILE: .mvn/jvm.config
================================================
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
================================================
FILE: CHANGELOG.md
================================================
Change Log
==========
The change log for versions newer than 2.10 is available only on the [GitHub Releases page](https://github.com/google/gson/releases).
## Version 2.10
* Support for serializing and deserializing Java records, on Java ≥ 16. (https://github.com/google/gson/pull/2201)
* Add `JsonArray.asList` and `JsonObject.asMap` view methods (https://github.com/google/gson/pull/2225)
* Fix `TypeAdapterRuntimeTypeWrapper` not detecting reflective `TreeTypeAdapter` and `FutureTypeAdapter` (https://github.com/google/gson/pull/1787)
* Improve `JsonReader.skipValue()` (https://github.com/google/gson/pull/2062)
* Perform numeric conversion for primitive numeric type adapters (https://github.com/google/gson/pull/2158)
* Add `Gson.fromJson(..., TypeToken)` overloads (https://github.com/google/gson/pull/1700)
* Fix changes to `GsonBuilder` affecting existing `Gson` instances (https://github.com/google/gson/pull/1815)
* Make `JsonElement` conversion methods more consistent and fix javadoc (https://github.com/google/gson/pull/2178)
* Throw `UnsupportedOperationException` when `JsonWriter.jsonValue` is not supported (https://github.com/google/gson/pull/1651)
* Disallow `JsonObject` `Entry.setValue(null)` (https://github.com/google/gson/pull/2167)
* Fix `TypeAdapter.toJson` throwing AssertionError for custom IOException (https://github.com/google/gson/pull/2172)
* Convert null to JsonNull for `JsonArray.set` (https://github.com/google/gson/pull/2170)
* Fixed nullSafe usage. (https://github.com/google/gson/pull/1555)
* Validate `TypeToken.getParameterized` arguments (https://github.com/google/gson/pull/2166)
* Fix #1702: Gson.toJson creates CharSequence which does not implement toString (https://github.com/google/gson/pull/1703)
* Prefer existing adapter for concurrent `Gson.getAdapter` calls (https://github.com/google/gson/pull/2153)
* Improve `ArrayTypeAdapter` for `Object[]` (https://github.com/google/gson/pull/1716)
* Improve `AppendableWriter` performance (https://github.com/google/gson/pull/1706)
## Version 2.9.1
* Make `Object` and `JsonElement` deserialization iterative rather than
recursive (https://github.com/google/gson/pull/1912)
* Added parsing support for enum that has overridden toString() method (https://github.com/google/gson/pull/1950)
* Removed support for building Gson with Gradle (https://github.com/google/gson/pull/2081)
* Removed obsolete `codegen` hierarchy (https://github.com/google/gson/pull/2099)
* Add support for reflection access filter (https://github.com/google/gson/pull/1905)
* Improve `TypeToken` creation validation (https://github.com/google/gson/pull/2072)
* Add explicit support for `float` in `JsonWriter` (https://github.com/google/gson/pull/2130, https://github.com/google/gson/pull/2132)
* Fail when parsing invalid local date (https://github.com/google/gson/pull/2134)
Also many small improvements to javadoc.
## Version 2.9.0
**The minimum supported Java version changes from 6 to 7.**
* Change target Java version to 7 (https://github.com/google/gson/pull/2043)
* Put `module-info.class` into Multi-Release JAR folder (https://github.com/google/gson/pull/2013)
* Improve error message when abstract class cannot be constructed (https://github.com/google/gson/pull/1814)
* Support EnumMap deserialization (https://github.com/google/gson/pull/2071)
* Add LazilyParsedNumber default adapter (https://github.com/google/gson/pull/2060)
* Fix JsonReader.hasNext() returning true at end of document (https://github.com/google/gson/pull/2061)
* Remove Gradle build support. Build script was outdated and not actively
maintained anymore (https://github.com/google/gson/pull/2063)
* Add `GsonBuilder.disableJdkUnsafe()` (https://github.com/google/gson/pull/1904)
* Add `UPPER_CASE_WITH_UNDERSCORES` in FieldNamingPolicy (https://github.com/google/gson/pull/2024)
* Fix failing to serialize Collection or Map with inaccessible constructor (https://github.com/google/gson/pull/1902)
* Improve TreeTypeAdapter thread-safety (https://github.com/google/gson/pull/1976)
* Fix `Gson.newJsonWriter` ignoring lenient and HTML-safe setting (https://github.com/google/gson/pull/1989)
* Delete unused LinkedHashTreeMap (https://github.com/google/gson/pull/1992)
* Make default adapters stricter; improve exception messages (https://github.com/google/gson/pull/2000)
* Fix `FieldNamingPolicy.upperCaseFirstLetter` uppercasing non-letter (https://github.com/google/gson/pull/2004)
## Version 2.8.9
* Make OSGi bundle's dependency on `sun.misc` optional (https://github.com/google/gson/pull/1993).
* Deprecate `Gson.excluder()` exposing internal `Excluder` class (https://github.com/google/gson/pull/1986).
* Prevent Java deserialization of internal classes (https://github.com/google/gson/pull/1991).
* Improve number strategy implementation (https://github.com/google/gson/pull/1987).
* Fix LongSerializationPolicy null handling being inconsistent with Gson (https://github.com/google/gson/pull/1990).
* Support arbitrary Number implementation for Object and Number deserialization (https://github.com/google/gson/pull/1290).
* Bump proguard-maven-plugin from 2.4.0 to 2.5.1 (https://github.com/google/gson/pull/1980).
* Don't exclude static local classes (https://github.com/google/gson/pull/1969).
* Fix `RuntimeTypeAdapterFactory` depending on internal `Streams` class (https://github.com/google/gson/pull/1959).
* Improve Maven build (https://github.com/google/gson/pull/1964).
* Make dependency on `java.sql` optional (https://github.com/google/gson/pull/1707).
## Version 2.8.8
* Fixed issue with recursive types (https://github.com/google/gson/issues/1390).
* Better behaviour with Java 9+ and `Unsafe` if there is a security manager (https://github.com/google/gson/pull/1712).
* `EnumTypeAdapter` now works better when ProGuard has obfuscated enum fields (https://github.com/google/gson/pull/1495).
## Version 2.8.7
* Fixed `ISO8601UtilsTest` failing on systems with UTC+X.
* Improved javadoc for `JsonStreamParser`.
* Updated proguard.cfg (https://github.com/google/gson/pull/1693).
* Fixed `IllegalStateException` in `JsonTreeWriter` (https://github.com/google/gson/issues/1592).
* Added `JsonArray.isEmpty()` (https://github.com/google/gson/pull/1640).
* Added new test cases (https://github.com/google/gson/pull/1638).
* Fixed OSGi metadata generation to work on JavaSE < 9 (https://github.com/google/gson/pull/1603).
## Version 2.8.6
_2019-10-04_ [GitHub Diff](https://github.com/google/gson/compare/gson-parent-2.8.5...gson-parent-2.8.6)
* Added static methods `JsonParser.parseString` and `JsonParser.parseReader` and deprecated instance method `JsonParser.parse`
* Java 9 module-info support
## Version 2.8.5
_2018-05-21_ [GitHub Diff](https://github.com/google/gson/compare/gson-parent-2.8.4...gson-parent-2.8.5)
* Print Gson version while throwing AssertionError and IllegalArgumentException
* Moved `utils.VersionUtils` class to `internal.JavaVersion`. This is a potential backward incompatible change from 2.8.4
* Fixed issue https://github.com/google/gson/issues/1310 by supporting Debian Java 9
## Version 2.8.4
_2018-05-01_ [GitHub Diff](https://github.com/google/gson/compare/gson-parent-2.8.3...gson-parent-2.8.4)
* Added a new FieldNamingPolicy, `LOWER_CASE_WITH_DOTS` that mapps JSON name `someFieldName` to `some.field.name`
* Fixed issue https://github.com/google/gson/issues/1305 by removing compile/runtime dependency on `sun.misc.Unsafe`
## Version 2.8.3
_2018-04-27_ [GitHub Diff](https://github.com/google/gson/compare/gson-parent-2.8.2...gson-parent-2.8.3)
* Added a new API, `GsonBuilder.newBuilder()` that clones the current builder
* Preserving DateFormatter behavior on JDK 9
* Numerous other bugfixes
## Version 2.8.2
_2017-09-19_ [GitHub Diff](https://github.com/google/gson/compare/gson-parent-2.8.1...gson-parent-2.8.2)
* Introduced a new API, `JsonElement.deepCopy()`
* Numerous other bugfixes
## Version 2.8.1
_2017-05-30_ [GitHub Diff](https://github.com/google/gson/compare/gson-parent-2.8.0...gson-parent-2.8.1)
* New: `JsonObject.keySet()`
* `@JsonAdapter` annotation can now use `JsonSerializer` and `JsonDeserializer` as well.
## Version 2.8
_2016-10-26_ [GitHub Diff](https://github.com/google/gson/compare/gson-parent-2.7...gson-parent-2.8.0)
* New: `TypeToken.getParameterized()` and `TypeToken.getArray()` make it easier to
register or look up a `TypeAdapter`.
* New: `@JsonAdapter(nullSafe=true)` to specify that a custom type adapter handles null.
## Version 2.7
_2016-06-14_ [GitHub Diff](https://github.com/google/gson/compare/gson-parent-2.6.2...gson-parent-2.7)
* Added support for JsonSerializer/JsonDeserializer in @JsonAdapter annotation
* Exposing Gson properties excluder(), fieldNamingStrategy(), serializeNulls(), htmlSafe()
* Added JsonObject.size() method
* Added JsonWriter.value(Boolean value) method
* Using ArrayDeque, ConcurrentHashMap, and other JDK 1.6 features
* Better error reporting
* Plenty of other bug fixes
## Version 2.6.2
_2016-02-26_ [GitHub Diff](https://github.com/google/gson/compare/gson-parent-2.6.1...gson-parent-2.6.2)
* Fixed an NPE bug with @JsonAdapter annotation
* Added back OSGI manifest
* Some documentation typo fixes
## Version 2.6.1
_2016-02-11_ [GitHub Diff](https://github.com/google/gson/compare/gson-parent-2.6...gson-parent-2.6.1)
* Fix: The 2.6 release targeted Java 1.7, but we intend to target Java 1.6. The
2.6.1 release is identical to 2.6, but it targets Java 1.6.
## Version 2.6
_2016-02-11_ [GitHub Diff](https://github.com/google/gson/compare/gson-parent-2.5...gson-parent-2.6)
* Permit timezones without minutes in the default date adapter.
* Update reader and writer for RFC 7159. This means that strings, numbers,
booleans and null may be top-level values in JSON documents, even if the
reader is strict.
* New `setLenient()` method on `GsonBuilder`. This setting impacts the new
factory method `Gson.newJsonReader()`.
* Adapters discovered with `@JsonAdapter` are now null safe by default.
## Version 2.5
_2015-11-24_ [GitHub Diff](https://github.com/google/gson/compare/gson-parent-2.4...gson-parent-2.5)
* Updated minimum JDK version to 1.6
* Improved Date Deserialization by accepting many date formats
* Added support for `java.util.Currency`, `AtomicLong`, `AtomicLongArray`, `AtomicInteger`, `AtomicIntegerArray`, `AtomicBoolean`. This change is backward-incompatible because the earlier version of Gson used the default serialization which wasn't intuitive. We hope that these classes are not used enough to actually cause problems in the field.
* Improved debugging information when some exceptions are thrown
## Version 2.4
_2015-10-04_
* **Drop `IOException` from `TypeAdapter.toJson()`.** This is a binary-compatible change, but may
cause compiler errors where `IOExceptions` are being caught but no longer thrown. The correct fix
for this problem is to remove the unnecessary `catch` clause.
* New: `Gson.newJsonWriter` method returns configured `JsonWriter` instances.
* New: `@SerializedName` now works with [AutoValue’s][autovalue] abstract property methods.
* New: `@SerializedName` permits alternate names when deserializing.
* New: `JsonWriter#jsonValue` writes raw JSON values.
* New: APIs to add primitives directly to `JsonArray` instances.
* New: ISO 8601 date type adapter. Find this in _extras_.
* Fix: `FieldNamingPolicy` now works properly when running on a device with a Turkish locale.
[autovalue]: https://github.com/google/auto/tree/main/value
## Version 2.3.1
_2014-11-20_
* Added support to serialize objects with self-referential fields. The self-referential field is set to null in JSON. Previous version of Gson threw a StackOverflowException on encountering any self-referential fields.
* The most visible impact of this is that Gson can now serialize Throwable (Exception and Error)
* Added support for @JsonAdapter annotation on enums which are user defined types
* Fixed bug in getPath() with array of objects and arrays of arrays
* Other smaller bug fixes
## Version 2.3
_2014-08-11_
* The new @JsonAdapter annotation to specify a Json TypeAdapter for a class field
* JsonPath support: JsonReader.getPath() method returns the JsonPath expression
* New public methods in JsonArray (similar to the java.util.List): `contains(JsonElement), remove(JsonElement), remove(int index), set(int index, JsonElement element)`
* Many other smaller bug fixes
## Version 2.2.4
_2013-05-13_
* Fix internal map (LinkedHashTreeMap) hashing bug.
* Bug fix (Issue 511)
## Version 2.2.3
_2013-04-12_
* Fixes for possible DoS attack due to poor String hashing
## Version 2.2.2
_2012-07-02_
* Gson now allows a user to override default type adapters for Primitives and Strings. This behavior was allowed in earlier versions of Gson but was prohibited started Gson 2.0. We decided to allow it again: This enables a user to parse 1/0 as boolean values for compatibility with iOS JSON libraries.
* (Incompatible behavior change in `JsonParser`): In the past, if `JsonParser` encountered a stream that terminated prematurely, it returned `JsonNull`. This behavior wasn't correct because the stream had invalid JSON, not a null. `JsonParser` is now changed to throw `JsonSyntaxException` in this case. Note that if JsonParser (or Gson) encounter an empty stream, they still return `JsonNull`.
## Version 2.2.1
_2012-05-05_
* Very minor fixes
## Version 2.2
_2012-05-05_
* Added getDelegateAdapter in Gson class
* Fixed a security bug related to denial of service attack with Java HashMap String collisions.
## Version 2.1
_2011-12-30_ (Targeted Dec 31, 2011)
* Support for user-defined streaming type adapters
* continued performance enhancements
* Dropped support for type hierarchy instance creators. We don't expect this to be a problem. We'll also detect fewer errors where multiple type adapters can serialize the same type. With APIs like getNextTypeAdapter, this might actually be an improvement!
## Version 2.0
_2011-11-13_
#### Faster
* Previous versions first parsed complete document into a DOM-style model (JsonObject or JsonArray) and then bound data against that. Gson 2 does data binding directly from the stream parser.
#### More Predictable
* Objects are serialized and deserialized in the same way, regardless of where they occur in the object graph.
#### Changes to watch out for
* Gson 1.7 would serialize top-level nulls as "". 2.0 serializes them as "null".
```
String json = gson.toJson(null, Foo.class);
1.7: json == ""
2.0: json == "null"
```
* Gson 1.7 permitted duplicate map keys. 2.0 forbids them.
```
String json = "{'a':1,'a':2}";
Map<String, Integer> map = gson.fromJson(json, mapType);
1.7: map == {a=2}
2.0: JsonSyntaxException thrown
```
* Gson 1.7 won’t serialize subclass fields in collection elements. 2.0 adds this extra information.
```
List<Point2d> points = new ArrayList<Point2d>();
points.add(new Point3d(1, 2, 3));
String json = gson.toJson(points,
new TypeToken<List<Point2d>>() {}.getType());
1.7: json == "[{'x':1,'y':2}]"
2.0: json == "[{'x':1,'y':2,'z':3}]"
```
* Gson 1.7 binds single-element arrays as their contents. 2.0 doesn’t.
```
Integer i = gson.fromJson("[42]", Integer.class);
1.7: i == 42
2.0: JsonSyntaxException thrown
```
#### Other changes to be aware of
* Gson 2.0 doesn’t support type adapters for primitive types.
* Gson 1.7 uses arbitrary precision for primitive type conversion (so -122.08e-2132 != 0). Gson 2.0 uses double precision (so -122.08e-2132 == 0).
* Gson 1.7 sets subclass fields when an InstanceCreator returns a subclass when the value is a field of another object. Gson 2.0 sets fields of the requested type only.
* Gson 1.7 versioning never skips the top-level object. Gson 2.0 versioning applies to all objects.
* Gson 1.7 truncates oversized large integers. Gson 2.0 fails on them.
* Gson 2.0 permits integers to have .0 fractions like "1.0".
* Gson 1.7 throws IllegalStateException on circular references. Gson 2.0 lets the runtime throw a StackOverflowError.
## Version 1.7.2
_2011-09-30_ (Unplanned release)
* Fixed a threading issue in FieldAttributes (Issue 354)
## Version 1.7.1
_2011-04-13_ (Unplanned release)
* Fixed Gson jars in Maven Central repository
* Removed assembly-descriptor.xml and maven pom.xml/pom.properties files from Gson binary jar. This also ensures that jarjar can be run correctly on Gson.
## Version 1.7
_2011-04-12_ (Targeted: Jan 2011)
* No need to define no-args constructors for classes serialized with Gson
* Ability to register a hierarchical type adapter
* Support for serialization and deserialization of maps with complex keys
* Serialization and deserialization specific exclusion strategies
* Allow concrete data structure fields without type adapters
* Fixes "type" management (i.e. Wildcards, etc.)
* Major performance enhancements by reducing the need for Java reflection
See detailed announcement at this thread in the Gson Google Group.
## Version 1.6
_2010-11-24_ (Targeted: Oct, 2010)
* New stream parser APIs
* New parser that improves parsing performance significantly
## Version 1.5
_2010-08-19_ (Target Date: Aug 18, 2010)
* Added `UPPER_CAMEL_CASE_WITH_SPACES` naming policy
* Added SQL date and time support
* A number of performance improvements: Using caching of field annotations for speeding up reflection, replacing recursive calls in the parser with a for loop.
## Version 1.4 BETA
_2009_10_09_
* JsonStreamParser: A streaming parser API class to deserialize multiple JSON objects on a stream (such as a pipelined HTTP response)
* Raised the deserialization limit for byte and object arrays and collection to over 11MB from 80KB. See issue 96.
* While serializing, Gson now uses the actual type of a field. This allows serialization of base-class references holding sub-classes to the JSON for the sub-class. It also allows serialization of raw collections. See Issue 155, 156.
* Added a `Gson.toJsonTree()` method that serializes a Java object to a tree of JsonElements. See issue 110.
* Added a `Gson.fromJson(JsonElement)` method that deserializes from a Json parse tree.
* Updated `Expose` annotation to contain parameters serialize and deserialize to control whether a field gets serialized or deserialized. See issue 146.
* Added a new naming policy `LOWER_CASE_WITH_DASHES`
* Default date type adapter is now thread-safe. See Issue 162.
* `JsonElement.toString()` now outputs valid JSON after escaping characters properly. See issue 154.
* `JsonPrimitive.equals()` now returns true for two numbers if their values are equal. All integral types (long, int, short, byte, BigDecimal, Long, Integer, Short, Byte) are treated equivalent for comparison. Similarly, floating point types (double, float, BigDecimal, Double, Float) are treated equivalent as well. See issue 147.
* Fixed bugs in pretty printing. See issue 153.
* If a field causes circular reference error, Gson lists the field name instead of the object value. See issue 118.
* Gson now serializes a list with null elements correctly. See issue 117.
* Fixed issue 121, 123, 126.
* Support user defined exclusion strategies (Feature Request 138).
## Version 1.3
_2009-04-01_
* Fix security token to remove the `<data>` element.
* Changed JsonParser.parse method to be non-static
* Throw JsonParseExceptions instead of ClassCastExceptions and UnsupportedOperationExceptions
## Version 1.3 beta3
_2009-03-17_
* Supported custom mapping of field names by making `FieldNamingStrategy` public and allowing `FieldNamingStrategy` to be set in GsonBuilder. See issue 104.
* Added a new GsonBuilder setting `generateNonExecutableJson()` that prefixes the generated JSON with some text to make the output non-executable Javascript. Gson now recognizes this text from input while deserializing and filters it out. This feature is meant to prevent script sourcing attacks. See Issue 42.
* Supported deserialization of sets with elements that do not implement Comparable. See Issue 100
* Supported deserialization of floating point numbers without a sign after E. See Issue 94
## Version 1.3 beta2
_2009-02-05_
* Added a new Parser API. See issue 65
* Supported deserialization of java.util.Properties. See Issue 87
* Fixed the pretty printing of maps. See Issue 93
* Supported automatic conversion of strings into numeric and boolean types if possible. See Issue 89
* Supported deserialization of longs into strings. See Issue 82
## Version 1.3 beta1
_2009_01_ (Target Date Friday, Dec 15, 2008)
* Made JSON parser lenient by allowing unquoted member names while parsing. See Issue 41
* Better precision handling for floating points. See Issue 71, 72
* Support for deserialization of special double values: NaN, infinity and negative infinity. See Issue 81
* Backward compatibility issue found with serialization of `Collection<Object>` type. See Issue 73 and 83.
* Able to serialize null keys and/or values within a Map. See Issue 77
* Deserializing non-String value keys for Maps. See Issue 85.
* Support for clashing field name. See Issue 76.
* Removed the need to invoke instance creator if a deserializer is registered. See issues 37 and 69.
* Added default support for java.util.UUID. See Issue 79
* Changed `Gson.toJson()` methods to use `Appendable` instead of `Writer`. Issue 52. This requires that clients recompile their source code that uses Gson.
## Version 1.2.3
_2008-11-15_ (Target Date Friday, Oct 31, 2008)
* Added support to serialize raw maps. See issue 45
* Made Gson thread-safe by fixing Issue 63
* Fixed Issue 68 to allow default type adapters for primitive types to be replaced by custom type adapters.
* Relaxed the JSON parser to accept escaped slash (\/) as a valid character in the string. See Issue 66
## Version 1.2.2
_2008-10-14_ (Target Date: None, Unplanned)
* This version was released to fix Issue 58 which caused a regression bug in version 1.2.1. It includes the contents from the release 1.2.1
## Version 1.2.1
_2008-10-13_ (Target Date Friday, Oct 7, 2008)
**Note:** This release was abandoned since it caused a regression (Issue 58) bug.
* Includes updated parser for JSON that supports much larger strings. For example, Gson 1.2 failed at parsing a 100k string, Gson 1.2.1 has successfully parsed strings of size 15-20MB. The parser also is faster and consumes less memory since it uses a token match instead of a recursion-based Grammar production match. See Issue 47.
* Gson now supports field names with single quotes ' in addition to double quotes ". See Issue 55.
* Includes bug fixes for issue 46, 49, 51, 53, 54, and 56.
## Version 1.2
_2008-08-29_ (Target Date Tuesday Aug 26, 2008)
* Includes support for feature requests 21, 24, 29
* Includes bug fixes for Issue 22, Issue 23, Issue 25, Issue 26, Issue 32 , Issue 34, Issue 35, Issue 36, Issue 37, Issue 38, Issue 39
* Performance enhancements (see r137)
* Documentation updates
## Version 1.1.1
_2008-07-18_ (Target Date Friday, Aug 1, 2008)
* Includes fixes for Issue 19, Partial fix for Issue 20
## Version 1.1
_2008-07-01_ (Target Date Thursday, July 3, 2008)
* Includes fixes for Issue 9, Issue 16, Issue 18
## Version 1.0.1
_2008-06-17_ (Target Date Friday, Jun 13, 2008)
* Includes fixes for Issue 15, Issue 14, Issue 3, Issue 8
* Javadoc improvements
================================================
FILE: GsonDesignDocument.md
================================================
# Gson Design Document
This document presents issues that we faced while designing Gson. It is meant for advanced users or developers working on Gson. If you are interested in learning how to use Gson, see its user guide.
Some information in this document is outdated and does not reflect the current state of Gson. This information can however still be relevant for understanding the history of Gson.
## Navigating the Json tree or the target Type Tree while deserializing
When you are deserializing a Json string into an object of desired type, you can either navigate the tree of the input, or the type tree of the desired type. Gson uses the latter approach of navigating the type of the target object. This keeps you in tight control of instantiating only the type of objects that you are expecting (essentially validating the input against the expected "schema"). By doing this, you also ignore any extra fields that the Json input has but were not expected.
As part of Gson, we wrote a general purpose ObjectNavigator that can take any object and navigate through its fields calling a visitor of your choice.
## Supporting richer serialization semantics than deserialization semantics
Gson supports serialization of arbitrary collections, but can only deserialize genericized collections. this means that Gson can, in some cases, fail to deserialize Json that it wrote. This is primarily a limitation of the Java type system since when you encounter a Json array of arbitrary types there is no way to detect the types of individual elements. We could have chosen to restrict the serialization to support only generic collections, but chose not to. This is because often the user of the library are concerned with either serialization or deserialization, but not both. In such cases, there is no need to artificially restrict the serialization capabilities.
## Supporting serialization and deserialization of classes that are not under your control and hence can not be modified
Some Json libraries use annotations on fields or methods to indicate which fields should be used for Json serialization. That approach essentially precludes the use of classes from JDK or third-party libraries. We solved this problem by defining the notion of custom serializers and deserializers. This approach is not new, and was used by the JAX-RPC technology to solve essentially the same problem.
## Using Checked vs Unchecked exceptions to indicate a parsing error
We chose to use unchecked exceptions to indicate a parsing failure. This is primarily done because usually the client can not recover from bad input, and hence forcing them to catch a checked exception results in sloppy code in the `catch()` block.
## Creating class instances for deserialization
Gson needs to create a dummy class instance before it can deserialize Json data into its fields. We could have used Guice to get such an instance, but that would have resulted in a dependency on Guice. Moreover, it probably would have done the wrong thing since Guice is expected to return a valid instance, whereas we need to create a dummy one. Worse, Gson would overwrite the fields of that instance with the incoming data thereby modifying the instance for all subsequent Guice injections. This is clearly not a desired behavior. Hence, we create class instances by invoking the parameterless constructor. We also handle the primitive types, enums, collections, sets, maps and trees as a special case.
To solve the problem of supporting unmodifiable types, we use custom instance creators. So, if you want to use a library type that does not define a default constructor (for example, `Money` class), then you can register an instance creator that returns a dummy instance when asked.
## Using fields vs getters to indicate Json elements
Some Json libraries use the getters of a type to deduce the Json elements. We chose to use all fields (up the inheritance hierarchy) that are not transient, static, or synthetic. We did this because not all classes are written with suitably named getters. Moreover, `getXXX` or `isXXX` might be semantic rather than indicating properties.
However, there are good arguments to support properties as well. We intend to enhance Gson in a later version to support properties as an alternate mapping for indicating Json fields. For now, Gson is fields-based.
## Why are most classes in Gson marked as final?
While Gson provides a fairly extensible architecture by providing pluggable serializers and deserializers, Gson classes were not specifically designed to be extensible. Providing non-final classes would have allowed a user to legitimately extend Gson classes, and then expect that behavior to work in all subsequent revisions. We chose to limit such use-cases by marking classes as final, and waiting until a good use-case emerges to allow extensibility. Marking a class final also has a minor benefit of providing additional optimization opportunities to Java compiler and virtual machine.
## Why are inner interfaces and classes used heavily in Gson?
Gson uses inner classes substantially. Many of the public interfaces are inner interfaces too (see `JsonSerializer.Context` or `JsonDeserializer.Context` as an example). These are primarily done as a matter of style. For example, we could have moved `JsonSerializer.Context` to be a top-level class `JsonSerializerContext`, but chose not to do so. However, if you can give us good reasons to rename it alternately, we are open to changing this philosophy.
## Why do you provide two ways of constructing Gson?
Gson can be constructed in two ways: by invoking `new Gson()` or by using a `GsonBuilder`. We chose to provide a simple no-args constructor to handle simple use-cases for Gson where you want to use default options, and quickly want to get going with writing code. For all other situations, where you need to configure Gson with options such as formatters, version controls etc., we use a builder pattern. The builder pattern allows a user to specify multiple optional settings for what essentially become constructor parameters for Gson.
## Comparing Gson with alternate approaches
Note that these comparisons were done while developing Gson so these date back to mid to late 2007.
### Comparing Gson with org.json library
org.json is a much lower-level library that can be used to write a `toJson()` method in a class. If you can not use Gson directly (maybe because of platform restrictions regarding reflection), you could use org.json to hand-code a `toJson` method in each object.
### Comparing Gson with org.json.simple library
org.json.simple library is very similar to org.json library and hence fairly low level. The key issue with this library is that it does not handle exceptions very well. In some cases it appeared to just eat the exception while in other cases it throws an "Error" rather than an exception.
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
# Gson
Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object.
Gson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of.
There are a few open-source projects that can convert Java objects to JSON. However, most of them require that you place Java annotations in your classes; something that you can not do if you do not have access to the source-code. Most also do not fully support the use of Java Generics. Gson considers both of these as very important design goals.
> [!NOTE]\
> Gson is currently in maintenance mode; existing bugs will be fixed, but large new features will likely not be added. If you want to add a new feature, please first search for existing GitHub issues, or create a new one to discuss the feature and get feedback.
> [!IMPORTANT]\
> Gson's main focus is on Java. Using it with other JVM languages such as Kotlin or Scala might work fine in many cases, but language-specific features such as Kotlin's non-`null` types or constructors with default arguments are not supported. This can lead to confusing and incorrect behavior.\
> When using languages other than Java, prefer a JSON library with explicit support for that language.
> [!IMPORTANT]\
> Gson is not a recommended library for interacting with JSON on Android. The open-ended reflection in the Gson runtime doesn't play nicely with shrinking/optimization/obfuscation passes that Android release apps should perform.\
> If your app or library may be running on Android, consider using [Kotlin Serialization](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/basic-serialization.md#basics) or [Moshi's Codegen](https://github.com/square/moshi?tab=readme-ov-file#codegen),
> which use code generation instead of reflection. This avoids Gson's runtime crashes when optimizations are applied (usually due to the fields missing or being obfuscated), and results in faster performance on Android devices.
> The Moshi APIs may be more familiar to users who already know Gson.
> If you still want to use Gson and attempt to avoid these crashes, you can see how to do so [here](Troubleshooting.md#proguard-r8).
### Goals
* Provide simple `toJson()` and `fromJson()` methods to convert Java objects to JSON and vice-versa
* Allow pre-existing unmodifiable objects to be converted to and from JSON
* Extensive support of Java Generics
* Allow custom representations for objects
* Support arbitrarily complex objects (with deep inheritance hierarchies and extensive use of generic types)
### Download
Gradle:
```gradle
dependencies {
implementation 'com.google.code.gson:gson:2.13.2'
}
```
Maven:
```xml
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.13.2</version>
</dependency>
```
[Gson jar downloads](https://maven-badges.herokuapp.com/maven-central/com.google.code.gson/gson) are available from Maven Central.

### Requirements
#### Minimum Java version
- Gson 2.12.0 and newer: Java 8
- Gson 2.9.0 to 2.11.0: Java 7
- Gson 2.8.9 and older: Java 6
Despite supporting older Java versions, Gson also provides a JPMS module descriptor (module name `com.google.gson`) for users of Java 9 or newer.
#### JPMS dependencies (Java 9+)
These are the optional Java Platform Module System (JPMS) JDK modules which Gson depends on.
This only applies when running Java 9 or newer.
- `java.sql` (optional since Gson 2.8.9)\
When this module is present, Gson provides default adapters for some SQL date and time classes.
- `jdk.unsupported`, respectively class `sun.misc.Unsafe` (optional)\
When this module is present, Gson can use the `Unsafe` class to create instances of classes without no-args constructor.
However, care should be taken when relying on this. `Unsafe` is not available in all environments and its usage has some pitfalls,
see [`GsonBuilder.disableJdkUnsafe()`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/GsonBuilder.html#disableJdkUnsafe()).
#### Minimum Android API level
- Gson 2.11.0 and newer: API level 21
- Gson 2.10.1 and older: API level 19
Older Gson versions may also support lower API levels, however this has not been verified.
### Documentation
* [API Javadoc](https://www.javadoc.io/doc/com.google.code.gson/gson): Documentation for the current release
* [User guide](UserGuide.md): This guide contains examples on how to use Gson in your code
* [Troubleshooting guide](Troubleshooting.md): Describes how to solve common issues when using Gson
* [Releases and change log](https://github.com/google/gson/releases): Latest releases and changes in these versions; for older releases see [`CHANGELOG.md`](CHANGELOG.md)
* [Design document](GsonDesignDocument.md): This document discusses issues we faced while designing Gson. It also includes a comparison of Gson with other Java libraries that can be used for Json conversion
Please use the ['gson' tag on StackOverflow](https://stackoverflow.com/questions/tagged/gson), [GitHub Discussions](https://github.com/google/gson/discussions) or the [google-gson Google group](https://groups.google.com/group/google-gson) to discuss Gson or to post questions.
### ProGuard / R8
See the details in the related section in the [Troubleshooting guide](Troubleshooting.md#proguard-r8).
### Related Content Created by Third Parties
* [Gson Tutorial](https://www.studytrails.com/java/json/java-google-json-introduction/) by `StudyTrails`
* [Gson Tutorial Series](https://futurestud.io/tutorials/gson-getting-started-with-java-json-serialization-deserialization) by `Future Studio`
* [Gson API Report](https://abi-laboratory.pro/java/tracker/timeline/gson/)
### Building
Gson uses Maven to build the project:
```
mvn clean verify
```
JDK 17 or newer is required for building, JDK 21 is recommended. Newer JDKs are currently not supported for building (but are supported when _using_ Gson).
### Contributing
See the [contributing guide](https://github.com/google/.github/blob/master/CONTRIBUTING.md).\
Please perform a quick search to check if there are already existing issues or pull requests related to your contribution.
Keep in mind that Gson is in maintenance mode. If you want to add a new feature, please first search for existing GitHub issues, or create a new one to discuss the feature and get feedback.
### License
Gson is released under the [Apache 2.0 license](LICENSE).
```
Copyright 2008 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
### Disclaimer
This is not an officially supported Google product.
================================================
FILE: ReleaseProcess.md
================================================
# Gson Release Process
The following is a step-by-step procedure for releasing a new version of Google-Gson.
1. Go through all open bugs and identify which will be fixed in this release. Mark all others with an appropriate release tag. Identify duplicates, and close the bugs that will never be fixed. Fix all bugs for the release, and mark them fixed.
1. Ensure all changelists are code-reviewed and have +1
1. Make sure your `${user.home}/.m2/settings.xml` contains the [Maven Central credentials](https://central.sonatype.org/publish/publish-portal-maven/#credentials)
1. `cd gson` to the parent directory; ensure there are no open files and all changes are committed.
1. Run `mvn release:clean`
1. Start the release: `mvn release:prepare`
- Answer questions: usually the defaults are fine. Try to follow [Semantic Versioning](https://semver.org/) when choosing the release version number.
- This will do a full build, change version from `-SNAPSHOT` to the released version, commit and create the tags. It will then change the version to `-SNAPSHOT` for the next release.
1. Complete the release: `mvn release:perform`
1. [Log in to the Central Portal](https://central.sonatype.com/)
1. Download and sanity check all files.\
Do not skip this step! Once you release the staging repository, there is no going back. It will get synced with Maven Central and you will not be able to update or delete anything. Your only recourse will be to release a new version of Gson and hope that no one uses the old one.
1. Publish the new Gson version in the Central Portal.\
Gson will now get synced to Maven Central within the next hour.
1. Create a [GitHub release](https://github.com/google/gson/releases) for the new version.\
You can let GitHub [automatically generate the description for the release](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes), but you should edit it manually to point out the most important changes and potentially incompatible changes.
1. Update version references in (version might be referenced multiple times):
- [`README.md`](README.md)
- [`UserGuide.md`](UserGuide.md)
Note: When using the Maven Release Plugin as described above, these version references should have been replaced automatically, but verify this manually nonetheless to be on the safe side.
1. Optional: Create a post on the [Gson Discussion Forum](https://groups.google.com/group/google-gson).
1. Optional: Update the release version in [Wikipedia](https://en.wikipedia.org/wiki/Gson) and update the current "stable" release.
Important: When aborting a release / rolling back release preparations, make sure to also revert all changes to files which were done during the release (e.g. automatic replacement of version references).
## Testing Maven release workflow locally
The following describes how to perform the steps of the release locally to verify that they work as desired.
> [!CAUTION]\
> Be careful with this, these steps might be outdated or incomplete. Double-check that you are working on a copy of your local Gson Git repository and make sure you have followed all steps. To be safe you can also temporarily turn off your internet connection to avoid accidentally pushing changes to the real remote Git or Maven repository.\
> As an alternative to the steps described below you can instead [perform a dry run](https://maven.apache.org/maven-release/maven-release-plugin/usage.html#do-a-dry-run), though this might not behave identical to a real release.
1. Make a copy of your local Gson Git repository and only work with that copy
1. Make sure you are on the `main` branch
1. Create a temp directory outside the Gson directory\
In the following steps this will be called `#gson-remote-temp#`; replace this with the actual absolute file path of the directory, using only forward slashes. For example under Windows `C:\my-dir` becomes `C:/my-dir`.
1. Create the directory `#gson-remote-temp#/git-repo`
1. In that directory run
```sh
git init --bare --initial-branch=main .
```
1. Edit the root `pom.xml` of Gson
1. Change the `<developerConnection>` to
```txt
scm:git:file:///#gson-remote-temp#/git-repo
```
1. For the `central-publishing-maven-plugin` **inside the `<pluginManagement>`**, add the following to its `<configuration>`
```xml
<skipPublishing>true</skipPublishing>
```
1. If you don't want to use GPG, remove the `maven-gpg-plugin` entry from the 'release' profile.\
There is also an entry under `<pluginManagement>`; you can remove that as well.
1. Commit the changes using Git
1. Change the remote repository of the Git project
<!-- Uses `txt` instead of `sh` to avoid the `#` being highlighted in some way -->
```txt
git remote set-url origin file:///#gson-remote-temp#/git-repo
```
1. Push the changes
```sh
git push origin main
```
Now you can perform the steps of the release:
1. ```sh
mvn release:clean
```
1. ```sh
mvn release:prepare
```
1. ```sh
mvn release:perform
```
1. Verify that `#gson-remote-temp#/git-repo` contains the desired changes
1. Verify that in the Gson project directory where you performed the release, the `target/checkout/target/central-publishing/central-bundle.zip` file contains the desired artifacts\
Currently that is the artifacts for `gson-parent` and `gson`.
1. Afterwards delete all Gson files under `${user.home}/.m2/repository/com/google/code/gson` which have been installed in your local Maven repository during the release.\
Otherwise Maven might not download the real Gson artifacts with these version numbers, once they are released.
## Running Benchmarks or Tests on Android
* Download vogar
* Put `adb` on your `$PATH` and run:
```bash
vogar --benchmark --classpath gson.jar path/to/Benchmark.java
```
For example, here is how to run the [CollectionsDeserializationBenchmark](gson/src/main/java/com/google/gson/metrics/CollectionsDeserializationBenchmark.java):
```bash
export ANDROID_HOME=~/apps/android-sdk-mac_x86
export PATH=$PATH:$ANDROID_HOME/platform-tools/:$ANDROID_HOME/android-sdk-mac_x86/tools/
$VOGAR_HOME/bin/vogar \
--benchmark \
--sourcepath ../gson/src/main/java/ \
src/main/java/com/google/gson/metrics/CollectionsDeserializationBenchmark.java \
-- \
--vm "app_process -Xgc:noconcurrent,app_process"
```
================================================
FILE: Troubleshooting.md
================================================
# Troubleshooting Guide
This guide describes how to troubleshoot common issues when using Gson.
<!-- The '<a id="..."></a>' anchors below are used to create stable links; don't remove or rename them -->
<!-- Use only lowercase IDs, GitHub seems to not support uppercase IDs, see also https://github.com/orgs/community/discussions/50962 -->
## <a id="class-cast-exception"></a> `ClassCastException` when using deserialized object
**Symptom:** `ClassCastException` is thrown when accessing an object deserialized by Gson
**Reason:**
- Your code is most likely not type-safe
- Or, you have not configured code shrinking tools such as ProGuard or R8 correctly
**Solution:** Make sure your code adheres to the following:
- Avoid raw types: Instead of calling `fromJson(..., List.class)`, create for example a `TypeToken<List<MyClass>>`.
See the [user guide](UserGuide.md#collections-examples) for more information.
- When using `TypeToken` prefer the `Gson.fromJson` overloads with `TypeToken` parameter such as [`fromJson(Reader, TypeToken)`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/Gson.html#fromJson(java.io.Reader,com.google.gson.reflect.TypeToken)).
The overloads with `Type` parameter do not provide any type-safety guarantees.
- When using `TypeToken` make sure you don't capture a type variable. For example avoid something like `new TypeToken<List<T>>()` (where `T` is a type variable). Due to Java [type erasure](https://dev.java/learn/generics/type-erasure/) the actual type of `T` is not available at runtime. Refactor your code to pass around `TypeToken` instances or use [`TypeToken.getParameterized(...)`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/reflect/TypeToken.html#getParameterized(java.lang.reflect.Type,java.lang.reflect.Type...)), for example `TypeToken.getParameterized(List.class, elementType)` where `elementType` is a type you have to provide separately.
If you are using a code shrinking tool such as ProGuard / R8 (for example when building an Android app), make sure it is correctly configured to keep generic signatures and to keep Gson's `TypeToken` class.
See the [ProGuard / R8](#proguard-r8) section for more information.
## <a id="reflection-inaccessible"></a> `InaccessibleObjectException`: 'module ... does not "opens ..." to unnamed module'
**Symptom:** An exception with a message in the form 'module ... does not "opens ..." to unnamed module' is thrown
**Reason:** You use Gson by accident to access internal fields of third-party classes
**Solution:** Write custom Gson [`TypeAdapter`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/TypeAdapter.html) implementations for the affected classes or change the type of your data.
If you already wrote a custom adapter, but it is not used, see [this troubleshooting point](#custom-adapter-not-used).\
If this occurs for a field in one of your classes which you did not actually want to serialize or deserialize in the first place, you can exclude that field, see the [user guide](UserGuide.md#excluding-fields-from-serialization-and-deserialization).
**Explanation:**
When no built-in adapter for a type exists and no custom adapter has been registered, Gson falls back to using reflection to access the fields of a class (including `private` ones). Most likely you are seeing this error because you (by accident) rely on the reflection-based adapter for third-party classes. That should be avoided because you make yourself dependent on the implementation details of these classes which could change at any point. For the JDK it is also not possible anymore to access internal fields using reflection starting with JDK 17, see [JEP 403](https://openjdk.org/jeps/403).
If you want to prevent using reflection on third-party classes in the future you can write your own [`ReflectionAccessFilter`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/ReflectionAccessFilter.html) or use one of the predefined ones, such as `ReflectionAccessFilter.BLOCK_ALL_PLATFORM`.
## <a id="reflection-inaccessible-to-module-gson"></a> `InaccessibleObjectException`: 'module ... does not "opens ..." to module com.google.gson'
**Symptom:** An exception with a message in the form 'module ... does not "opens ..." to module com.google.gson' is thrown
**Reason:**
- If the reported package is your own package then you have not configured the module declaration of your project to allow Gson to use reflection on your classes.
- If the reported package is from a third party library or the JDK see [this troubleshooting point](#inaccessibleobjectexception-module--does-not-opens--to-unnamed-module).
**Solution:** Make sure the `module-info.java` file of your project allows Gson to use reflection on your classes, for example:
```java
module mymodule {
requires com.google.gson;
opens mypackage to com.google.gson;
}
```
Or in case this occurs for a field in one of your classes which you did not actually want to serialize or deserialize in the first place, you can exclude that field, see the [user guide](UserGuide.md#excluding-fields-from-serialization-and-deserialization).
## <a id="android-app-random-names"></a> Android app not working in Release mode; random property names
**Symptom:** Your Android app is working fine in Debug mode but fails in Release mode and the JSON properties have seemingly random names such as `a`, `b`, ...
**Reason:** You probably have not configured ProGuard / R8 correctly
**Solution:** Make sure you have configured ProGuard / R8 correctly to preserve the names of your fields.
See the section below, it's related to this issue.
## <a id="android-app-broken-after-app-update"></a> Android app unable to parse JSON after app update
**Symptom:** You released a new version of your Android app and it fails to parse JSON data created by the previous version of your app
**Reason:** You probably have not configured ProGuard / R8 correctly; probably the field names are being obfuscated and their naming changed between the versions of your app
**Solution:** Make sure you have configured ProGuard / R8 correctly to preserve the names of your fields.
See the [ProGuard / R8](#proguard-r8) section for more information.
If you want to preserve backward compatibility for you app you can use [`@SerializedName`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/annotations/SerializedName.html) on the fields to specify the obfuscated name as alternate, for example: `@SerializedName(value = "myprop", alternate = "a")`
Normally ProGuard and R8 produce a mapping file, this makes it easier to find out the obfuscated field names instead of having to find them out through trial and error or other means. See the [Android Studio user guide](https://developer.android.com/studio/build/shrink-code.html#retracing) for more information.
## <a id="default-field-values-missing"></a> Default field values not present after deserialization
**Symptom:** You have assign default values to fields but after deserialization the fields have their standard value (such as `null` or `0`)
**Reason:** Gson cannot invoke the constructor of your class and falls back to JDK `Unsafe` (or similar means)
**Solution:** Make sure that the class:
- is `static` (explicitly or implicitly when it is a top-level class)
- has a no-args constructor
Otherwise Gson will by default try to use JDK `Unsafe` or similar means to create an instance of your class without invoking the constructor and without running any initializers. You can also disable that behavior through [`GsonBuilder.disableJdkUnsafe()`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/GsonBuilder.html#disableJdkUnsafe()) to notice such issues early on.
## <a id="anonymous-local-null"></a> `null` values for anonymous and local classes
**Symptom:** Objects of a class are always serialized as JSON `null` / always deserialized as Java `null`
**Reason:** The class you are serializing or deserializing is an anonymous or a local class (or you have specified a custom `ExclusionStrategy`)
**Solution:** Convert the class to a `static` nested class. If the class is already `static` make sure you have not specified a Gson `ExclusionStrategy` which might exclude the class.
Notes:
- "double brace-initialization" also creates anonymous classes
- Local record classes (feature added in Java 16) are supported by Gson and are not affected by this
## <a id="map-key-wrong-json"></a> Map keys having unexpected format in JSON
**Symptom:** JSON output for `Map` keys is unexpected / cannot be deserialized again
**Reason:** The `Map` key type is 'complex' and you have not configured the `GsonBuilder` properly
**Solution:** Use [`GsonBuilder.enableComplexMapKeySerialization()`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/GsonBuilder.html#enableComplexMapKeySerialization()). See also the [user guide](UserGuide.md#maps-examples) for more information.
## <a id="malformed-json"></a> Parsing JSON fails with `MalformedJsonException`
**Symptom:** JSON parsing fails with `MalformedJsonException`
**Reason:** The JSON data is actually malformed
**Solution:** During debugging, log the JSON data right before calling Gson methods or set a breakpoint to inspect the data and make sure it has the expected format. Sometimes APIs might return HTML error pages (instead of JSON data) when reaching rate limits or when other errors occur. Also read the location information of the `MalformedJsonException` exception message, it indicates where exactly in the document the malformed data was detected, including the [JSONPath](https://goessner.net/articles/JsonPath/).
For example, let's assume you want to deserialize the following JSON data:
```json
{
"languages": [
"English",
"French",
]
}
```
This will fail with an exception similar to this one: `MalformedJsonException: Use JsonReader.setStrictness(Strictness.LENIENT) to accept malformed JSON at line 5 column 4 path $.languages[2]`\
The problem here is the trailing comma (`,`) after `"French"`, trailing commas are not allowed by the JSON specification. The location information "line 5 column 4" points to the `]` in the JSON data (with some slight inaccuracies) because Gson expected another value after `,` instead of the closing `]`. The JSONPath `$.languages[2]` in the exception message also points there: `$.` refers to the root object, `languages` refers to its member of that name and `[2]` refers to the (missing) third value in the JSON array value of that member (numbering starts at 0, so it is `[2]` instead of `[3]`).\
The proper solution here is to fix the malformed JSON data.
To spot syntax errors in the JSON data easily you can open it in an editor with support for JSON, for example Visual Studio Code. It will highlight within the JSON data the error location and show why the JSON data is considered invalid.
## <a id="number-parsed-as-double"></a> Integral JSON number is parsed as `double`
**Symptom:** JSON data contains an integral number such as `45` but Gson returns it as `double`
**Reason:** When parsing a JSON number as `Object`, Gson will by default always return a `double`
**Solution:** Use [`GsonBuilder.setObjectToNumberStrategy`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/GsonBuilder.html#setObjectToNumberStrategy(com.google.gson.ToNumberStrategy)) to specify what type of number should be returned
## <a id="default-lenient"></a> Malformed JSON not rejected
**Symptom:** Gson parses malformed JSON without throwing any exceptions
**Reason:** Due to legacy reasons Gson performs parsing by default in lenient mode
**Solution:** If you are using Gson 2.11.0 or newer, call [`GsonBuilder.setStrictness`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/GsonBuilder.html#setStrictness(com.google.gson.Strictness)),
[`JsonReader.setStrictness`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/stream/JsonReader.html#setStrictness(com.google.gson.Strictness))
and [`JsonWriter.setStrictness`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/stream/JsonWriter.html#setStrictness(com.google.gson.Strictness))
with `Strictness.STRICT` to overwrite the default lenient behavior of `Gson` and make these classes strictly adhere to the JSON specification.
Otherwise if you are using an older Gson version, see the [`Gson` class documentation](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/Gson.html#default-lenient)
section "JSON Strictness handling" for alternative solutions.
## <a id="unexpected-json-structure"></a> `IllegalStateException`: "Expected ... but was ..."
**Symptom:** An `IllegalStateException` with a message in the form "Expected ... but was ..." is thrown
**Reason:**
- The JSON data does not have the correct format
- Or, Gson has no built-in adapter for a type and tries to deserialize it as JSON object
**Solution:** Make sure that your classes correctly model the JSON data. Also during debugging log the JSON data right before calling Gson methods or set a breakpoint to inspect the data and make sure it has the expected format. Read the location information of the exception message, it indicates where exactly in the document the error occurred, including the [JSONPath](https://goessner.net/articles/JsonPath/).
For example, let's assume you have the following Java class:
```java
class WebPage {
String languages;
}
```
And you want to deserialize the following JSON data:
```json
{
"languages": ["English", "French"]
}
```
This will fail with an exception similar to this one: `IllegalStateException: Expected a string but was BEGIN_ARRAY at line 2 column 17 path $.languages`\
This means Gson expected a JSON string value but found the beginning of a JSON array (`[`). The location information "line 2 column 17" points to the `[` in the JSON data (with some slight inaccuracies), so does the JSONPath `$.languages` in the exception message. It refers to the `languages` member of the root object (`$.`).\
The solution here is to change in the `WebPage` class the field `String languages` to `List<String> languages`.
If you are sure that the JSON data is correct and the exception message is "Expected BEGIN_OBJECT but was ...", then this might indicate that Gson has no built-in adapter for the type.
Gson then tries to use reflection and expects that the data is a JSON object (hence the error message "Expected BEGIN_OBJECT ..."). In that case you have to write a custom [`TypeAdapter`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/TypeAdapter.html) for that type. If you already wrote a custom adapter, but it is not used, see [this troubleshooting point](#custom-adapter-not-used).
## <a id="adapter-not-null-safe"></a> `IllegalStateException`: "Expected ... but was NULL"
**Symptom:** An `IllegalStateException` with a message in the form "Expected ... but was NULL" is thrown
**Reason:**
- A built-in adapter does not support JSON null values
- Or, you have written a custom `TypeAdapter` which does not properly handle JSON null values
**Solution:** If this occurs for a custom adapter you wrote, add code similar to the following at the beginning of its `read` method:
```java
@Override
public MyClass read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
...
}
```
Alternatively you can call [`nullSafe()`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/TypeAdapter.html#nullSafe()) on the adapter instance you created.
## <a id="serialize-nulls"></a> Properties missing in JSON
**Symptom:** Properties are missing in the JSON output
**Reason:** Gson by default omits JSON null from the output\
(or: ProGuard / R8 is not configured correctly and removed unused fields, see the [ProGuard / R8](#proguard-r8) section)
**Solution:** Use [`GsonBuilder.serializeNulls()`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/GsonBuilder.html#serializeNulls())
Note: Gson does not support anonymous and local classes and will serialize them as JSON null, see the [related troubleshooting point](#null-values-for-anonymous-and-local-classes).
## <a id="android-internal-fields"></a> JSON output changes for newer Android versions
**Symptom:** The JSON output differs when running on newer Android versions
**Reason:** You use Gson by accident to access internal fields of Android classes
**Solution:** Write custom Gson [`TypeAdapter`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/TypeAdapter.html) implementations for the affected classes or change the type of your data
**Explanation:**
When no built-in adapter for a type exists and no custom adapter has been registered, Gson falls back to using reflection to access the fields of a class (including `private` ones). Most likely you are experiencing this issue because you (by accident) rely on the reflection-based adapter for Android classes. That should be avoided because you make yourself dependent on the implementation details of these classes which could change at any point.
If you want to prevent using reflection on third-party classes in the future you can write your own [`ReflectionAccessFilter`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/ReflectionAccessFilter.html) or use one of the predefined ones, such as `ReflectionAccessFilter.BLOCK_ALL_PLATFORM`.
## <a id="json-static-fields"></a> JSON output contains values of `static` fields
**Symptom:** The JSON output contains values of `static` fields
**Reason:** You used `GsonBuilder.excludeFieldsWithModifiers` to overwrite the default excluded modifiers
**Solution:** When calling `GsonBuilder.excludeFieldsWithModifiers` you overwrite the default excluded modifiers. Therefore, you have to explicitly exclude `static` fields if desired. This can be done by adding `Modifier.STATIC` as additional argument to the `excludeFieldsWithModifiers` call.
## <a id="no-such-method-error"></a> `NoSuchMethodError` when calling Gson methods
**Symptom:** A `java.lang.NoSuchMethodError` is thrown when trying to call certain Gson methods
**Reason:**
- You have multiple versions of Gson on your classpath
- Or, the Gson version you compiled against is different from the one on your classpath
- Or, you are using a code shrinking tool such as ProGuard or R8 which removed methods from Gson
**Solution:** First disable any code shrinking tools such as ProGuard or R8 and check if the issue persists. If not, you have to tweak the configuration of that tool to not modify Gson classes. Otherwise verify that the Gson JAR on your classpath is the same you are compiling against, and that there is only one Gson JAR on your classpath. See [this Stack Overflow question](https://stackoverflow.com/q/227486) to find out where a class is loaded from. For example, for debugging you could include the following code:
```java
System.out.println(Gson.class.getProtectionDomain().getCodeSource().getLocation());
```
If that fails with a `NullPointerException` you have to try one of the other ways to find out where a class is loaded from.
## <a id="duplicate-fields"></a> `IllegalArgumentException`: 'Class ... declares multiple JSON fields named '...''
**Symptom:** An exception with the message 'Class ... declares multiple JSON fields named '...'' is thrown
**Reason:**
- The name you have specified with a [`@SerializedName`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/annotations/SerializedName.html) annotation for a field collides with the name of another field
- Or, the [`FieldNamingStrategy`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/FieldNamingStrategy.html) you have specified produces conflicting field names
- Or, a field of your class has the same name as the field of a superclass
- Or, you are using an obfuscation tool such as ProGuard or R8, and it has renamed the fields; in that case see the [ProGuard / R8](#proguard-r8) section
Gson prevents multiple fields with the same name because during deserialization it would be ambiguous for which field the JSON data should be deserialized. For serialization it would cause the same field to appear multiple times in JSON. While the JSON specification permits this, it is likely that the application parsing the JSON data will not handle it correctly.
**Solution:** First identify the fields with conflicting names based on the exception message. Then decide if you want to rename one of them using the [`@SerializedName`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/annotations/SerializedName.html) annotation or a [`FieldNamingStrategy`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/FieldNamingStrategy.html), or if you want to [exclude](UserGuide.md#excluding-fields-from-serialization-and-deserialization) one of them. When excluding one of the fields you have to apply the exclusion for both serialization and deserialization (even if your application only performs one of these actions) because the duplicate field check cannot differentiate between these actions.
## <a id="java-lang-class-unsupported"></a> `UnsupportedOperationException` when serializing or deserializing `java.lang.Class`
**Symptom:** An `UnsupportedOperationException` is thrown when trying to serialize or deserialize `java.lang.Class`
**Reason:** Gson intentionally does not permit serializing and deserializing `java.lang.Class` for security reasons. Otherwise a malicious user could make your application load an arbitrary class from the classpath and, depending on what your application does with the `Class`, in the worst case perform a remote code execution attack.
**Solution:** First check if you really need to serialize or deserialize a `Class`. Often it is possible to use string aliases and then map them to the known `Class`; you could write a custom [`TypeAdapter`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/TypeAdapter.html) to do this. If the `Class` values are not known in advance, try to introduce a common base class or interface for all these classes and then verify that the deserialized class is a subclass. For example assuming the base class is called `MyBaseClass`, your custom `TypeAdapter` should load the class like this:
```java
Class.forName(jsonString, false, getClass().getClassLoader()).asSubclass(MyBaseClass.class)
```
This will not initialize arbitrary classes, and it will throw a `ClassCastException` if the loaded class is not the same as or a subclass of `MyBaseClass`.
## <a id="custom-adapter-not-used"></a> Custom type adapter is not used
**Symptom:** You have registered a custom `TypeAdapter` (or `JsonSerializer` or `JsonDeserializer`) on a `GsonBuilder`, but Gson is not using your adapter
**Reason:**
- You registered the adapter for the wrong type
- Or, you are serializing or deserializing a subclass
- Or, your custom `Gson` instance is not actually used
**Solution:**
- Debug your code and verify that the custom `Gson` instance on which you have registered the adapter is actually used. Possibly parts of your application are using a different `Gson` instance, or you are using a framework such as Spring which is using a different `Gson` instance with default configuration (in that case have a look at the framework-specific configuration options).
- Verify that you are registering the adapter for the correct type. `GsonBuilder.registerTypeAdapter(...)` takes the adapter as `Object` argument, so you will not see a compilation error when you provide the wrong type.
For example when you want to register an adapter for `MyClass`, you should call `registerTypeAdapter(MyClass.class, new MyClassAdapter())`.\
Also pay close attention to the package name, there are classes with the same name in different packages, such as `java.util.Date` and `java.sql.Date`.
- `registerTypeAdapter` only registers an adapter for the specified class, _but not for subclasses_. Use [`registerTypeHierarchyAdapter`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/GsonBuilder.html#registerTypeHierarchyAdapter(java.lang.Class,java.lang.Object))
to also handle subclasses.
- Be careful with parameterized types for `registerTypeAdapter` because Gson only uses the adapter if there is an exact match for the types.
For example if you register an adapter for `List<Number>` it won't be used for `List` (raw type), `List<Integer>` or `ArrayList<Number>`.
You can solve this by writing a [`TypeAdapterFactory`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/TypeAdapterFactory.html) instead, which manually checks if the type matches.
- If you want to register an adapter for a primitive type such as `boolean`, you might also want to register it for the wrapper type `java.lang.Boolean`, and the other way around.
- The built-in adapters for `JsonElement` (and subclasses) and for `Object` cannot be overwritten. However, as workaround for a field of those types you can use the [`@JsonAdapter` annotation](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/annotations/JsonAdapter.html) to specify a custom adapter.
## <a id="type-token-raw"></a> `IllegalStateException`: 'TypeToken must be created with a type argument' <br> `RuntimeException`: 'Missing type parameter'
**Symptom:** An `IllegalStateException` with the message 'TypeToken must be created with a type argument' is thrown.\
For older Gson versions a `RuntimeException` with message 'Missing type parameter' is thrown.
**Reason:**
- You created a `TypeToken` without type argument, for example `new TypeToken() {}` (note the missing `<...>`). You always have to provide the type argument, for example like this: `new TypeToken<List<String>>() {}`. Normally the compiler will also emit a 'raw types' warning when you forget the `<...>`.
- Or, you are using a code shrinking tool such as ProGuard or R8 (Android app builds normally have this enabled by default) but have not configured it correctly for usage with Gson.
**Solution:** When you are using a code shrinking tool such as ProGuard or R8 you have to adjust your configuration to include the following rules:
```
# Keep generic signatures; needed for correct type resolution
-keepattributes Signature
# Keep class TypeToken (respectively its generic signature)
-keep class com.google.gson.reflect.TypeToken { *; }
# Keep any (anonymous) classes extending TypeToken
-keep class * extends com.google.gson.reflect.TypeToken
```
See the [ProGuard / R8](#proguard-r8) section for more information.
Note: For newer Gson versions these rules might be applied automatically; make sure you are using the latest Gson version and the latest version of the code shrinking tool.
## <a id="r8-abstract-class"></a> `JsonIOException`: 'Abstract classes can't be instantiated!' (R8)
**Symptom:** A `JsonIOException` with the message 'Abstract classes can't be instantiated!' is thrown; the class mentioned in the exception message is not actually `abstract` in your source code, and you are using the code shrinking tool R8 (Android app builds normally have this configured by default).
Note: If the class which you are trying to deserialize is actually abstract, then this exception is probably unrelated to R8 and you will have to implement a custom [`InstanceCreator`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/InstanceCreator.html) or [`TypeAdapter`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/TypeAdapter.html) which creates an instance of a non-abstract subclass of the class. If you already wrote a custom adapter, but it is not used, see [this troubleshooting point](#custom-adapter-not-used).
**Reason:** The code shrinking tool R8 performs optimizations where it removes the no-args constructor from a class and makes the class `abstract`. Due to this Gson cannot create an instance of the class.
**Solution:** Make sure the class has a no-args constructor, then adjust your R8 configuration file to keep the constructor of the class. For example:
```
# Keep the no-args constructor of the deserialized class
-keepclassmembers class com.example.MyClass {
<init>();
}
```
You can also use `<init>(...);` to keep all constructors of that class, but then you might actually rely on `sun.misc.Unsafe` on both JDK and Android to create classes without no-args constructor, see [`GsonBuilder.disableJdkUnsafe()`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/GsonBuilder.html#disableJdkUnsafe()) for more information.
For Android you can add this rule to the `proguard-rules.pro` file, see also the [Android documentation](https://developer.android.com/build/shrink-code#keep-code). In case the class name in the exception message is obfuscated, see the Android documentation about [retracing](https://developer.android.com/build/shrink-code#retracing).
For Android you can alternatively use the [`@Keep` annotation](https://developer.android.com/studio/write/annotations#keep) on the class or constructor you want to keep. That might be easier than having to maintain a custom R8 configuration.
Note that the latest Gson versions (2.11.0 or newer) specify a default R8 configuration. See the [ProGuard / R8](#proguard-r8) section for more information.
## <a id="typetoken-type-variable"></a> `IllegalArgumentException`: 'TypeToken type argument must not contain a type variable'
**Symptom:** An exception with the message 'TypeToken type argument must not contain a type variable' is thrown
**Reason:** This exception is thrown when you create an anonymous `TypeToken` subclass which captures a type variable, for example `new TypeToken<List<T>>() {}` (where `T` is a type variable). At compile time such code looks safe and you can use the type `List<T>` without any warnings. However, this code is not actually type-safe because at runtime due to [type erasure](https://dev.java/learn/generics/type-erasure/) only the upper bound of the type variable is available. For the previous example that would be `List<Object>`. When using such a `TypeToken` with any Gson methods performing deserialization this would lead to confusing and difficult to debug `ClassCastException`s. For serialization it can in some cases also lead to undesired results.
Note: Earlier version of Gson unfortunately did not prevent capturing type variables, which caused many users to unwittingly write type-unsafe code.
**Solution:**
- Use [`TypeToken.getParameterized(...)`](https://www.javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/reflect/TypeToken.html#getParameterized(java.lang.reflect.Type,java.lang.reflect.Type...)), for example `TypeToken.getParameterized(List.class, elementType)` where `elementType` is a type you have to provide separately.
- For Kotlin users: Use [`reified` type parameters](https://kotlinlang.org/docs/inline-functions.html#reified-type-parameters), that means change `<T>` to `<reified T>`, if possible. If you have a chain of functions with type parameters you will probably have to make all of them `reified`.
- If you don't actually use Gson's `TypeToken` for any Gson method, use a general purpose 'type token' implementation provided by a different library instead, for example Guava's [`com.google.common.reflect.TypeToken`](https://javadoc.io/doc/com.google.guava/guava/latest/com/google/common/reflect/TypeToken.html).
For backward compatibility it is possible to restore Gson's old behavior of allowing `TypeToken` to capture type variables by setting the [system property](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/System.html#setProperty(java.lang.String,java.lang.String)) `gson.allowCapturingTypeVariables` to `"true"`, **however**:
- This does not solve any of the type-safety problems mentioned above; in the long term you should prefer one of the other solutions listed above. This system property might be removed in future Gson versions.
- You should only ever set the property to `"true"`, but never to any other value or manually clear it. Otherwise this might counteract any libraries you are using which might have deliberately set the system property because they rely on its behavior.
## <a id="proguard-r8"></a> Android - R8 / ProGuard
Gson is not recommended on Android due to the expectation of R8 optimization, or other environments where you intend to minify (shrink/optimize/obfuscate) your build, such as with ProGuard. While it is possible to make it work with minification, many features of the library will not work in this environment due to the open ended reflection performed in Gson. This is true even with the most up to date ProGuard file, included since Gson 2.11.0.
If you do want to make Gson work with minification, you must test your code after minification has been applied, and can choose to either:
### Constrain reflected classes
- Ensure all of your objects have a no-arg constructor (and be a top-level or static class to avoid implicit constructor arguments)
- Annotate all fields with `@SerializedName()`
If you still use a Gson version older than 2.11.0 or if you are using ProGuard for a non-Android project ([related ProGuard issue](https://github.com/Guardsquare/proguard/issues/337)),
you may need to copy the rules from Gson's [`gson.pro`](gson/src/main/resources/META-INF/proguard/gson.pro) file into your own ProGuard configuration file.
### Avoid Reflection
It is possible to avoid reflection when using Gson. This will mean you will need to have a `TypeAdapter` or `TypeAdapterFactory` for every type you might want to serialize or deserialize, or that you are only using Gson through its explicit JSON API via classes like `JsonObject` and `JsonArray`, or are manually reading or writing JSON data using `JsonReader` and `JsonWriter`. You can ensure reflection isn't being used by calling [`GsonBuilder.addReflectionAccessFilter()`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/GsonBuilder.html#addReflectionAccessFilter(com.google.gson.ReflectionAccessFilter)) to add a filter which always returns `BLOCK_ALL`.
================================================
FILE: UserGuide.md
================================================
# Gson User Guide
1. [Overview](#overview)
2. [Goals for Gson](#goals-for-gson)
3. [Gson Performance and Scalability](#gson-performance-and-scalability)
4. [Gson Users](#gson-users)
5. [Using Gson](#using-gson)
* [Using Gson with Gradle/Android](#using-gson-with-gradleandroid)
* [Using Gson with Maven](#using-gson-with-maven)
* [Primitives Examples](#primitives-examples)
* [Object Examples](#object-examples)
* [Finer Points with Objects](#finer-points-with-objects)
* [Nested Classes (including Inner Classes)](#nested-classes-including-inner-classes)
* [Array Examples](#array-examples)
* [Collections Examples](#collections-examples)
* [Collections Limitations](#collections-limitations)
* [Maps Examples](#maps-examples)
* [Serializing and Deserializing Generic Types](#serializing-and-deserializing-generic-types)
* [Serializing and Deserializing Collection with Objects of Arbitrary Types](#serializing-and-deserializing-collection-with-objects-of-arbitrary-types)
* [Built-in Serializers and Deserializers](#built-in-serializers-and-deserializers)
* [Custom Serialization and Deserialization](#custom-serialization-and-deserialization)
* [Writing a Serializer](#writing-a-serializer)
* [Writing a Deserializer](#writing-a-deserializer)
* [Writing an Instance Creator](#writing-an-instance-creator)
* [InstanceCreator for a Parameterized Type](#instancecreator-for-a-parameterized-type)
* [Compact Vs. Pretty Printing for JSON Output Format](#compact-vs-pretty-printing-for-json-output-format)
* [Null Object Support](#null-object-support)
* [Versioning Support](#versioning-support)
* [Excluding Fields From Serialization and Deserialization](#excluding-fields-from-serialization-and-deserialization)
* [Java Modifier Exclusion](#java-modifier-exclusion)
* [Gson's `@Expose`](#gsons-expose)
* [User Defined Exclusion Strategies](#user-defined-exclusion-strategies)
* [JSON Field Naming Support](#json-field-naming-support)
* [Sharing State Across Custom Serializers and Deserializers](#sharing-state-across-custom-serializers-and-deserializers)
* [Streaming](#streaming)
6. [Issues in Designing Gson](#issues-in-designing-gson)
7. [Future Enhancements to Gson](#future-enhancements-to-gson)
## Overview
Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object.
Gson can work with arbitrary Java objects including pre-existing objects that you do not have source code of.
## Goals for Gson
* Provide easy to use mechanisms like `toString()` and constructor (factory method) to convert Java to JSON and vice-versa
* Allow pre-existing unmodifiable objects to be converted to and from JSON
* Allow custom representations for objects
* Support arbitrarily complex objects
* Generate compact and readable JSON output
## Gson Performance and Scalability
Here are some metrics that we obtained on a desktop (dual opteron, 8GB RAM, 64-bit Ubuntu) running lots of other things along-with the tests. You can rerun these tests by using the class [`PerformanceTest`](gson/src/test/java/com/google/gson/metrics/PerformanceTest.java).
* Strings: Deserialized strings of over 25MB without any problems (see `disabled_testStringDeserializationPerformance` method in `PerformanceTest`)
* Large collections:
* Serialized a collection of 1.4 million objects (see `disabled_testLargeCollectionSerialization` method in `PerformanceTest`)
* Deserialized a collection of 87,000 objects (see `disabled_testLargeCollectionDeserialization` in `PerformanceTest`)
* Gson 1.4 raised the deserialization limit for byte arrays and collection to over 11MB from 80KB.
Note: Delete the `disabled_` prefix to run these tests. We use this prefix to prevent running these tests every time we run JUnit tests.
## Gson Users
Gson was originally created for use inside Google where it is currently used in a number of projects. It is now used by a number of public projects and companies.
## Using Gson
The primary class to use is [`Gson`](gson/src/main/java/com/google/gson/Gson.java) which you can just create by calling `new Gson()`. There is also a class [`GsonBuilder`](gson/src/main/java/com/google/gson/GsonBuilder.java) available that can be used to create a Gson instance with various settings like version control and so on.
The Gson instance does not maintain any state while invoking JSON operations. So, you are free to reuse the same object for multiple JSON serialization and deserialization operations.
## Using Gson with Gradle/Android
```gradle
dependencies {
implementation 'com.google.code.gson:gson:2.13.2'
}
```
## Using Gson with Maven
To use Gson with Maven2/3, you can use the Gson version available in Maven Central by adding the following dependency:
```xml
<dependencies>
<!-- Gson: Java to JSON conversion -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.13.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
```
That is it, now your Maven project is Gson enabled.
### Primitives Examples
```java
// Serialization
Gson gson = new Gson();
gson.toJson(1); // ==> 1
gson.toJson("abcd"); // ==> "abcd"
gson.toJson(new Long(10)); // ==> 10
int[] values = { 1 };
gson.toJson(values); // ==> [1]
// Deserialization
int i = gson.fromJson("1", int.class);
Integer intObj = gson.fromJson("1", Integer.class);
Long longObj = gson.fromJson("1", Long.class);
Boolean boolObj = gson.fromJson("false", Boolean.class);
String str = gson.fromJson("\"abc\"", String.class);
String[] strArray = gson.fromJson("[\"abc\"]", String[].class);
```
### Object Examples
```java
class BagOfPrimitives {
private int value1 = 1;
private String value2 = "abc";
private transient int value3 = 3;
BagOfPrimitives() {
// no-args constructor
}
}
// Serialization
BagOfPrimitives obj = new BagOfPrimitives();
Gson gson = new Gson();
String json = gson.toJson(obj);
// ==> {"value1":1,"value2":"abc"}
```
Note that you can not serialize objects with circular references since that will result in infinite recursion.
```java
// Deserialization
BagOfPrimitives obj2 = gson.fromJson(json, BagOfPrimitives.class);
// ==> obj2 is just like obj
```
#### **Finer Points with Objects**
* It is perfectly fine (and recommended) to use private fields.
* There is no need to use any annotations to indicate a field is to be included for serialization and deserialization. All fields in the current class (and from all super classes) are included by default.
* If a field is marked transient, (by default) it is ignored and not included in the JSON serialization or deserialization.
* This implementation handles nulls correctly.
* While serializing, a null field is omitted from the output.
* While deserializing, a missing entry in JSON results in setting the corresponding field in the object to its default value: null for object types, zero for numeric types, and false for booleans.
* If a field is _synthetic_, it is ignored and not included in JSON serialization or deserialization.
* Fields corresponding to the outer classes in inner classes are ignored and not included in serialization or deserialization.
* Anonymous and local classes are excluded. They will be serialized as JSON `null` and when deserialized their JSON value is ignored and `null` is returned. Convert the classes to `static` nested classes to enable serialization and deserialization for them.
### Nested Classes (including Inner Classes)
Gson can serialize static nested classes quite easily.
Gson can also deserialize static nested classes. However, Gson can **not** automatically deserialize the **pure inner classes since their no-args constructor also need a reference to the containing Object** which is not available at the time of deserialization. You can address this problem by either making the inner class static or by providing a custom InstanceCreator for it. Here is an example:
```java
public class A {
public String a;
class B {
public String b;
public B() {
// No args constructor for B
}
}
}
```
**NOTE**: The above class B can not (by default) be serialized with Gson.
Gson can not deserialize `{"b":"abc"}` into an instance of B since the class B is an inner class. If it was defined as static class B then Gson would have been able to deserialize the string. Another solution is to write a custom instance creator for B.
```java
public class InstanceCreatorForB implements InstanceCreator<A.B> {
private final A a;
public InstanceCreatorForB(A a) {
this.a = a;
}
public A.B createInstance(Type type) {
return a.new B();
}
}
```
The above is possible, but not recommended.
### Array Examples
```java
Gson gson = new Gson();
int[] ints = {1, 2, 3, 4, 5};
String[] strings = {"abc", "def", "ghi"};
// Serialization
gson.toJson(ints); // ==> [1,2,3,4,5]
gson.toJson(strings); // ==> ["abc", "def", "ghi"]
// Deserialization
int[] ints2 = gson.fromJson("[1,2,3,4,5]", int[].class);
// ==> ints2 will be same as ints
```
We also support multi-dimensional arrays, with arbitrarily complex element types.
### Collections Examples
```java
Gson gson = new Gson();
Collection<Integer> ints = Arrays.asList(1,2,3,4,5);
// Serialization
String json = gson.toJson(ints); // ==> [1,2,3,4,5]
// Deserialization
TypeToken<Collection<Integer>> collectionType = new TypeToken<Collection<Integer>>(){};
// Note: For older Gson versions it is necessary to use `collectionType.getType()` as argument below,
// this is however not type-safe and care must be taken to specify the correct type for the local variable
Collection<Integer> ints2 = gson.fromJson(json, collectionType);
// ==> ints2 is same as ints
```
Fairly hideous: note how we define the type of collection.
Unfortunately, there is no way to get around this in Java.
#### Collections Limitations
Gson can serialize collection of arbitrary objects but can not deserialize from it, because there is no way for the user to indicate the type of the resulting object. Instead, while deserializing, the Collection must be of a specific, generic type.
This makes sense, and is rarely a problem when following good Java coding practices.
### Maps Examples
Gson by default serializes any `java.util.Map` implementation as a JSON object. Because JSON objects only support strings as member names, Gson converts the Map keys to strings by calling `toString()` on them, and using `"null"` for `null` keys:
```java
Gson gson = new Gson();
Map<String, String> stringMap = new LinkedHashMap<>();
stringMap.put("key", "value");
stringMap.put(null, "null-entry");
// Serialization
String json = gson.toJson(stringMap); // ==> {"key":"value","null":"null-entry"}
Map<Integer, Integer> intMap = new LinkedHashMap<>();
intMap.put(2, 4);
intMap.put(3, 6);
// Serialization
String json = gson.toJson(intMap); // ==> {"2":4,"3":6}
```
For deserialization Gson uses the `read` method of the `TypeAdapter` registered for the Map key type. Similar to the Collection example shown above, for deserialization a `TypeToken` has to be used to tell Gson what types the Map keys and values have:
```java
Gson gson = new Gson();
TypeToken<Map<String, String>> mapType = new TypeToken<Map<String, String>>(){};
String json = "{\"key\": \"value\"}";
// Deserialization
// Note: For older Gson versions it is necessary to use `mapType.getType()` as argument below,
// this is however not type-safe and care must be taken to specify the correct type for the local variable
Map<String, String> stringMap = gson.fromJson(json, mapType);
// ==> stringMap is {key=value}
```
Gson also supports using complex types as Map keys. This feature can be enabled with [`GsonBuilder.enableComplexMapKeySerialization()`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/GsonBuilder.html#enableComplexMapKeySerialization()). If enabled, Gson uses the `write` method of the `TypeAdapter` registered for the Map key type to serialize the keys, instead of using `toString()`. When any of the keys is serialized by the adapter as JSON array or JSON object, Gson will serialize the complete Map as JSON array, consisting of key-value pairs (encoded as JSON array). Otherwise, if none of the keys is serialized as a JSON array or JSON object, Gson will use a JSON object to encode the Map:
```java
class PersonName {
String firstName;
String lastName;
PersonName(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
// ... equals and hashCode
}
Gson gson = new GsonBuilder().enableComplexMapKeySerialization().create();
Map<PersonName, Integer> complexMap = new LinkedHashMap<>();
complexMap.put(new PersonName("John", "Doe"), 30);
complexMap.put(new PersonName("Jane", "Doe"), 35);
// Serialization; complex map is serialized as a JSON array containing key-value pairs (as JSON arrays)
String json = gson.toJson(complexMap);
// ==> [[{"firstName":"John","lastName":"Doe"},30],[{"firstName":"Jane","lastName":"Doe"},35]]
Map<String, String> stringMap = new LinkedHashMap<>();
stringMap.put("key", "value");
// Serialization; non-complex map is serialized as a regular JSON object
String json = gson.toJson(stringMap); // ==> {"key":"value"}
```
**Important:** Because Gson by default uses `toString()` to serialize Map keys, this can lead to malformed encoded keys or can cause mismatch between serialization and deserialization of the keys, for example when `toString()` is not properly implemented. A workaround for this can be to use `enableComplexMapKeySerialization()` to make sure the `TypeAdapter` registered for the Map key type is used for deserialization _and_ serialization. As shown in the example above, when none of the keys are serialized by the adapter as JSON array or JSON object, the Map is serialized as a regular JSON object, as desired.
Note that when deserializing enums as Map keys, if Gson is unable to find an enum constant with a matching `name()` value respectively `@SerializedName` annotation, it falls back to looking up the enum constant by its `toString()` value. This is to work around the issue described above, but only applies to enum constants.
### Serializing and Deserializing Generic Types
When you call `toJson(obj)`, Gson calls `obj.getClass()` to get information on the fields to serialize. Similarly, you can typically pass `MyClass.class` object in the `fromJson(json, MyClass.class)` method. This works fine if the object is a non-generic type. However, if the object is of a generic type, then the Generic type information is lost because of Java Type Erasure. Here is an example illustrating the point:
```java
class Foo<T> {
T value;
}
Gson gson = new Gson();
Foo<Bar> foo = new Foo<Bar>();
gson.toJson(foo); // May not serialize foo.value correctly
gson.fromJson(json, foo.getClass()); // Fails to deserialize foo.value as Bar
```
The above code fails to interpret value as type Bar because Gson invokes `foo.getClass()` to get its class information, but this method returns a raw class, `Foo.class`. This means that Gson has no way of knowing that this is an object of type `Foo<Bar>`, and not just plain `Foo`.
You can solve this problem by specifying the correct parameterized type for your generic type. You can do this by using the [`TypeToken`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/reflect/TypeToken.html) class.
```java
Type fooType = new TypeToken<Foo<Bar>>() {}.getType();
gson.toJson(foo, fooType);
gson.fromJson(json, fooType);
```
The idiom used to get `fooType` actually defines an anonymous local inner class containing a method `getType()` that returns the fully parameterized type.
### Serializing and Deserializing Collection with Objects of Arbitrary Types
Sometimes you are dealing with JSON array that contains mixed types. For example:
`['hello',5,{name:'GREETINGS',source:'guest'}]`
The equivalent `Collection` containing this is:
```java
Collection collection = new ArrayList();
collection.add("hello");
collection.add(5);
collection.add(new Event("GREETINGS", "guest"));
```
where the `Event` class is defined as:
```java
class Event {
private String name;
private String source;
private Event(String name, String source) {
this.name = name;
this.source = source;
}
}
```
You can serialize the collection with Gson without doing anything specific: `toJson(collection)` would write out the desired output.
However, deserialization with `fromJson(json, Collection.class)` will not work since Gson has no way of knowing how to map the input to the types. Gson requires that you provide a genericized version of the collection type in `fromJson()`. So, you have three options:
1. Use Gson's parser API (low-level streaming parser or the DOM parser JsonParser) to parse the array elements and then use `Gson.fromJson()` on each of the array elements.This is the preferred approach. [Here is an example](extras/src/main/java/com/google/gson/extras/examples/rawcollections/RawCollectionsExample.java) that demonstrates how to do this.
2. Register a type adapter for `Collection.class` that looks at each of the array members and maps them to appropriate objects. The disadvantage of this approach is that it will screw up deserialization of other collection types in Gson.
3. Register a type adapter for `MyCollectionMemberType` and use `fromJson()` with `Collection<MyCollectionMemberType>`.
This approach is practical only if the array appears as a top-level element or if you can change the field type holding the collection to be of type `Collection<MyCollectionMemberType>`.
### Built-in Serializers and Deserializers
Gson has built-in serializers and deserializers for commonly used classes whose default representation may be inappropriate, for instance
* `java.net.URL` to match it with strings like `"https://github.com/google/gson/"`
* `java.net.URI` to match it with strings like `"/google/gson/"`
For many more, see the internal class [`TypeAdapters`](gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java).
### Custom Serialization and Deserialization
Sometimes the default representation is not what you want. This is often the case when dealing with library classes (DateTime, etc.).
Gson allows you to register your own custom serializers and deserializers. This is done by defining two parts:
* JSON Serializers: Need to define custom serialization for an object
* JSON Deserializers: Needed to define custom deserialization for a type
* Instance Creators: Not needed if no-args constructor is available or a deserializer is registered
```java
GsonBuilder gson = new GsonBuilder();
gson.registerTypeAdapter(MyType2.class, new MyTypeAdapter());
gson.registerTypeAdapter(MyType.class, new MySerializer());
gson.registerTypeAdapter(MyType.class, new MyDeserializer());
gson.registerTypeAdapter(MyType.class, new MyInstanceCreator());
```
`registerTypeAdapter` call checks
1. if the type adapter implements more than one of these interfaces, in that case it registers the adapter for all of them.
2. if the type adapter is for the Object class or JsonElement or any of its subclasses, in that case it throws IllegalArgumentException because overriding the built-in adapters for these types is not supported.
#### Writing a Serializer
Here is an example of how to write a custom serializer for JodaTime `DateTime` class.
```java
private class DateTimeSerializer implements JsonSerializer<DateTime> {
public JsonElement serialize(DateTime src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(src.toString());
}
}
```
Gson calls `serialize()` when it runs into a `DateTime` object during serialization.
#### Writing a Deserializer
Here is an example of how to write a custom deserializer for JodaTime DateTime class.
```java
private class DateTimeDeserializer implements JsonDeserializer<DateTime> {
public DateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
return new DateTime(json.getAsJsonPrimitive().getAsString());
}
}
```
Gson calls `deserialize` when it needs to deserialize a JSON string fragment into a DateTime object
**Finer points with Serializers and Deserializers**
Often you want to register a single handler for all generic types corresponding to a raw type
* For example, suppose you have an `Id` class for id representation/translation (i.e. an internal vs. external representation).
* `Id<T>` type that has same serialization for all generic types
* Essentially write out the id value
* Deserialization is very similar but not exactly the same
* Need to call `new Id(Class<T>, String)` which returns an instance of `Id<T>`
Gson supports registering a single handler for this. You can also register a specific handler for a specific generic type (say `Id<RequiresSpecialHandling>` needed special handling).
The `Type` parameter for the `toJson()` and `fromJson()` contains the generic type information to help you write a single handler for all generic types corresponding to the same raw type.
### Writing an Instance Creator
While deserializing an Object, Gson needs to create a default instance of the class.
Well-behaved classes that are meant for serialization and deserialization should have a no-argument constructor.
* Doesn't matter whether public or private
Typically, Instance Creators are needed when you are dealing with a library class that does NOT define a no-argument constructor
**Instance Creator Example**
```java
private class MoneyInstanceCreator implements InstanceCreator<Money> {
public Money createInstance(Type type) {
return new Money("1000000", CurrencyCode.USD);
}
}
```
Type could be of a corresponding generic type
* Very useful to invoke constructors which need specific generic type information
* For example, if the `Id` class stores the class for which the Id is being created
#### InstanceCreator for a Parameterized Type
Sometimes the type that you are trying to instantiate is a parameterized type. Generally, this is not a problem since the actual instance is of raw type. Here is an example:
```java
class MyList<T> extends ArrayList<T> {
}
class MyListInstanceCreator implements InstanceCreator<MyList<?>> {
@SuppressWarnings("unchecked")
public MyList<?> createInstance(Type type) {
// No need to use a parameterized list since the actual instance will have the raw type anyway.
return new MyList();
}
}
```
However, sometimes you do need to create instance based on the actual parameterized type. In this case, you can use the type parameter being passed to the `createInstance` method. Here is an example:
```java
public class Id<T> {
private final Class<T> classOfId;
private final long value;
public Id(Class<T> classOfId, long value) {
this.classOfId = classOfId;
this.value = value;
}
}
class IdInstanceCreator implements InstanceCreator<Id<?>> {
public Id<?> createInstance(Type type) {
Type[] typeParameters = ((ParameterizedType)type).getActualTypeArguments();
Type idType = typeParameters[0]; // Id has only one parameterized type T
return new Id((Class)idType, 0L);
}
}
```
In the above example, an instance of the Id class can not be created without actually passing in the actual type for the parameterized type. We solve this problem by using the passed method parameter, `type`. The `type` object in this case is the Java parameterized type representation of `Id<Foo>` where the actual instance should be bound to `Id<Foo>`. Since `Id` class has just one parameterized type parameter, `T`, we use the zeroth element of the type array returned by `getActualTypeArgument()` which will hold `Foo.class` in this case.
### Compact Vs. Pretty Printing for JSON Output Format
The default JSON output that is provided by Gson is a compact JSON format. This means that there will not be any whitespace in the output JSON structure. Therefore, there will be no whitespace between field names and its value, object fields, and objects within arrays in the JSON output. As well, "null" fields will be ignored in the output (NOTE: null values will still be included in collections/arrays of objects). See the [Null Object Support](#null-object-support) section for information on configure Gson to output all null values.
If you would like to use the Pretty Print feature, you must configure your `Gson` instance using the `GsonBuilder`. The `JsonFormatter` is not exposed through our public API, so the client is unable to configure the default print settings/margins for the JSON output. For now, we only provide a default `JsonPrintFormatter` that has default line length of 80 character, 2 character indentation, and 4 character right margin.
The following is an example shows how to configure a `Gson` instance to use the default `JsonPrintFormatter` instead of the `JsonCompactFormatter`:
```java
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String jsonOutput = gson.toJson(someObject);
```
### Null Object Support
The default behaviour that is implemented in Gson is that `null` object fields are ignored. This allows for a more compact output format; however, the client must define a default value for these fields as the JSON format is converted back into its Java form.
Here's how you would configure a `Gson` instance to output null:
```java
Gson gson = new GsonBuilder().serializeNulls().create();
```
NOTE: when serializing `null`s with Gson, it will add a `JsonNull` element to the `JsonElement` structure. Therefore, this object can be used in custom serialization/deserialization.
Here's an example:
```java
public class Foo {
private final String s;
private final int i;
public Foo() {
this(null, 5);
}
public Foo(String s, int i) {
this.s = s;
this.i = i;
}
}
Gson gson = new GsonBuilder().serializeNulls().create();
Foo foo = new Foo();
String json = gson.toJson(foo);
System.out.println(json);
json = gson.toJson(null);
System.out.println(json);
```
The output is:
```json
{"s":null,"i":5}
null
```
### Versioning Support
Multiple versions of the same object can be maintained by using [@Since](gson/src/main/java/com/google/gson/annotations/Since.java) annotation. This annotation can be used on Classes, Fields and, in a future release, Methods. In order to leverage this feature, you must configure your `Gson` instance to ignore any field/object that is greater than some version number. If no version is set on the `Gson` instance then it will serialize and deserialize all fields and classes regardless of the version.
```java
public class VersionedClass {
@Since(1.1) private final String newerField;
@Since(1.0) private final String newField;
private final String field;
public VersionedClass() {
this.newerField = "newer";
this.newField = "new";
this.field = "old";
}
}
VersionedClass versionedObject = new VersionedClass();
Gson gson = new GsonBuilder().setVersion(1.0).create();
String jsonOutput = gson.toJson(versionedObject);
System.out.println(jsonOutput);
System.out.println();
gson = new Gson();
jsonOutput = gson.toJson(versionedObject);
System.out.println(jsonOutput);
```
The output is:
```json
{"newField":"new","field":"old"}
{"newerField":"newer","newField":"new","field":"old"}
```
### Excluding Fields From Serialization and Deserialization
Gson supports numerous mechanisms for excluding top-level classes, fields and field types. Below are pluggable mechanisms that allow field and class exclusion. If none of the below mechanisms satisfy your needs then you can always use [custom serializers and deserializers](#custom-serialization-and-deserialization).
#### Java Modifier Exclusion
By default, if you mark a field as `transient`, it will be excluded. As well, if a field is marked as `static` then by default it will be excluded. If you want to include some transient fields then you can do the following:
```java
import java.lang.reflect.Modifier;
Gson gson = new GsonBuilder()
.excludeFieldsWithModifiers(Modifier.STATIC)
.create();
```
NOTE: you can give any number of the `Modifier` constants to the `excludeFieldsWithModifiers` method. For example:
```java
Gson gson = new GsonBuilder()
.excludeFieldsWithModifiers(Modifier.STATIC, Modifier.TRANSIENT, Modifier.VOLATILE)
.create();
```
#### Gson's `@Expose`
This feature provides a way where you can mark certain fields of your objects to be excluded for consideration for serialization and deserialization to JSON. To use this annotation, you must create Gson by using `new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create()`. The Gson instance created will exclude all fields in a class that are not marked with `@Expose` annotation.
#### User Defined Exclusion Strategies
If the above mechanisms for excluding fields and class type do not work for you then you can always write your own exclusion strategy and plug it into Gson. See the [`ExclusionStrategy`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/ExclusionStrategy.html) JavaDoc for more information.
The following example shows how to exclude fields marked with a specific `@Foo` annotation and excludes top-level types (or declared field type) of class `String`.
```java
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface Foo {
// Field tag only annotation
}
public class SampleObjectForTest {
@Foo private final int annotatedField;
private final String stringField;
private final long longField;
public SampleObjectForTest() {
annotatedField = 5;
stringField = "someDefaultValue";
longField = 1234;
}
}
public class MyExclusionStrategy implements ExclusionStrategy {
private final Class<?> typeToSkip;
private MyExclusionStrategy(Class<?> typeToSkip) {
this.typeToSkip = typeToSkip;
}
public boolean shouldSkipClass(Class<?> clazz) {
return (clazz == typeToSkip);
}
public boolean shouldSkipField(FieldAttributes f) {
return f.getAnnotation(Foo.class) != null;
}
}
public static void main(String[] args) {
Gson gson = new GsonBuilder()
.setExclusionStrategies(new MyExclusionStrategy(String.class))
.serializeNulls()
.create();
SampleObjectForTest src = new SampleObjectForTest();
String json = gson.toJson(src);
System.out.println(json);
}
```
The output is:
```json
{"longField":1234}
```
### JSON Field Naming Support
Gson supports some pre-defined field naming policies to convert the standard Java field names (i.e., camel cased names starting with lower case --- `sampleFieldNameInJava`) to a JSON field name (i.e., `sample_field_name_in_java` or `SampleFieldNameInJava`). See the [FieldNamingPolicy](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/FieldNamingPolicy.html) class for information on the pre-defined naming policies.
It also has an annotation based strategy to allows clients to define custom names on a per field basis. Note, that the annotation based strategy has field name validation which will raise "Runtime" exceptions if an invalid field name is provided as the annotation value.
The following is an example of how to use both Gson naming policy features:
```java
private class SomeObject {
@SerializedName("custom_naming") private final String someField;
private final String someOtherField;
public SomeObject(String a, String b) {
this.someField = a;
this.someOtherField = b;
}
}
SomeObject someObject = new SomeObject("first", "second");
Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).create();
String jsonRepresentation = gson.toJson(someObject);
System.out.println(jsonRepresentation);
```
The output is:
```json
{"custom_naming":"first","SomeOtherField":"second"}
```
If you have a need for custom naming policy ([see this discussion](https://groups.google.com/group/google-gson/browse_thread/thread/cb441a2d717f6892)), you can use the [@SerializedName](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/annotations/SerializedName.html) annotation.
### Sharing State Across Custom Serializers and Deserializers
Sometimes you need to share state across custom serializers/deserializers ([see this discussion](https://groups.google.com/group/google-gson/browse_thread/thread/2850010691ea09fb)). You can use the following three strategies to accomplish this:
1. Store shared state in static fields
2. Declare the serializer/deserializer as inner classes of a parent type, and use the instance fields of parent type to store shared state
3. Use Java `ThreadLocal`
1 and 2 are not thread-safe options, but 3 is.
### Streaming
In addition Gson's object model and data binding, you can use Gson to read from and write to a stream with the classes [`JsonReader`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/stream/JsonReader.html) and [`JsonWriter`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/stream/JsonWriter.html). These classes operate on a JSON document as a sequence of tokens that are traversed in depth-first order. Because the streams operate on one token at a time, they impose minimal memory overhead.
You can also combine streaming and object model access to get the best of both approaches. For example by starting to manually read a JSON document using a `JsonReader` and then using [`Gson#fromJson(JsonReader, ...)`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/Gson.html#fromJson(com.google.gson.stream.JsonReader,java.lang.reflect.Type)) to read a nested value, or starting to manually write a JSON document using a `JsonWriter` and then using [`Gson#toJson(..., JsonWriter)`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/Gson.html#toJson(java.lang.Object,java.lang.reflect.Type,com.google.gson.stream.JsonWriter)) to write a nested value.
## Issues in Designing Gson
See the [Gson design document](GsonDesignDocument.md "Gson design document") for a discussion of issues we faced while designing Gson. It also includes a comparison of Gson with other Java libraries that can be used for JSON conversion.
## Future Enhancements to Gson
For the latest list of proposed enhancements or if you'd like to suggest new ones, see the [Issues section](https://github.com/google/gson/issues) under the project website.
================================================
FILE: extras/README.md
================================================
# extras
This Maven module contains the source code for supplementary Gson features which
are not included by default.
The artifacts created by this module are currently not deployed to Maven Central.
================================================
FILE: extras/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2011 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.google.code.gson</groupId>
<artifactId>gson-parent</artifactId>
<version>2.13.3-SNAPSHOT</version>
</parent>
<artifactId>gson-extras</artifactId>
<version>2.13.3-SNAPSHOT</version>
<inceptionYear>2008</inceptionYear>
<name>Gson Extras</name>
<description>Google Gson grab bag of utilities, type adapters, etc.</description>
<properties>
<!-- Make the build reproducible, see root `pom.xml` -->
<!-- This is duplicated here because that is recommended by `artifact:check-buildplan` -->
<project.build.outputTimestamp>2025-09-10T20:39:14Z</project.build.outputTimestamp>
</properties>
<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<organization>
<name>Google, Inc.</name>
<url>https://www.google.com</url>
</organization>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.13.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<developers>
<developer>
<name>Inderjeet Singh</name>
</developer>
<developer>
<name>Joel Leitch</name>
<organization>Google Inc.</organization>
</developer>
<developer>
<name>Jesse Wilson</name>
<organization>Square Inc.</organization>
</developer>
</developers>
<scm>
<tag>gson-extras-2.12.1</tag>
</scm>
</project>
================================================
FILE: extras/src/main/java/com/google/gson/extras/examples/rawcollections/RawCollectionsExample.java
================================================
/*
* Copyright (C) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gson.extras.examples.rawcollections;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Collection;
@SuppressWarnings({"PrivateConstructorForUtilityClass", "SystemOut"})
public class RawCollectionsExample {
static class Event {
private String name;
private String source;
private Event(String name, String source) {
this.name = name;
this.source = source;
}
@Override
public String toString() {
return String.format("(name=%s, source=%s)", name, source);
}
}
@SuppressWarnings({"unchecked", "rawtypes"})
public static void main(String[] args) {
Gson gson = new Gson();
Collection collection = new ArrayList();
collection.add("hello");
collection.add(5);
collection.add(new Event("GREETINGS", "guest"));
String json = gson.toJson(collection);
System.out.println("Using Gson.toJson() on a raw collection: " + json);
JsonArray array = JsonParser.parseString(json).getAsJsonArray();
String message = gson.fromJson(array.get(0), String.class);
int number = gson.fromJson(array.get(1), int.class);
Event event = gson.fromJson(array.get(2), Event.class);
System.out.printf("Using Gson.fromJson() to get: %s, %d, %s", message, number, event);
}
}
================================================
FILE: extras/src/main/java/com/google/gson/interceptors/Intercept.java
================================================
/*
* Copyright (C) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gson.interceptors;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Use this annotation to indicate various interceptors for class instances after they have been
* processed by Gson. For example, you can use it to validate an instance after it has been
* deserialized from Json. Here is an example of how this annotation is used:
*
* <p>Here is an example of how this annotation is used:
*
* <pre>
* @Intercept(postDeserialize=UserValidator.class)
* public class User {
* String name;
* String password;
* String emailAddress;
* }
*
* public class UserValidator implements JsonPostDeserializer<User> {
* public void postDeserialize(User user) {
* // Do some checks on user
* if (user.name == null || user.password == null) {
* throw new JsonParseException("name and password are required fields.");
* }
* if (user.emailAddress == null) {
* emailAddress = "unknown"; // assign a default value.
* }
* }
* }
* </pre>
*
* @author Inderjeet Singh
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Intercept {
/**
* Specify the class that provides the methods that should be invoked after an instance has been
* deserialized.
*/
@SuppressWarnings("rawtypes")
public Class<? extends JsonPostDeserializer> postDeserialize();
}
================================================
FILE: extras/src/main/java/com/google/gson/interceptors/InterceptorFactory.java
================================================
/*
* Copyright (C) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gson.interceptors;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
/** A type adapter factory that implements {@code @Intercept}. */
public final class InterceptorFactory implements TypeAdapterFactory {
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
Intercept intercept = type.getRawType().getAnnotation(Intercept.class);
if (intercept == null) {
return null;
}
TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
return new InterceptorAdapter<>(delegate, intercept);
}
static class InterceptorAdapter<T> extends TypeAdapter<T> {
private final TypeAdapter<T> delegate;
private final JsonPostDeserializer<T> postDeserializer;
@SuppressWarnings("unchecked") // ?
public InterceptorAdapter(TypeAdapter<T> delegate, Intercept intercept) {
try {
this.delegate = delegate;
this.postDeserializer = intercept.postDeserialize().getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public void write(JsonWriter out, T value) throws IOException {
delegate.write(out, value);
}
@Override
public T read(JsonReader in) throws IOException {
T result = delegate.read(in);
postDeserializer.postDeserialize(result);
return result;
}
}
}
================================================
FILE: extras/src/main/java/com/google/gson/interceptors/JsonPostDeserializer.java
================================================
/*
* Copyright (C) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gson.interceptors;
import com.google.gson.InstanceCreator;
/**
* This interface is implemented by a class that wishes to inspect or modify an object after it has
* been deserialized. You must define a no-args constructor or register an {@link InstanceCreator}
* for such a class.
*
* @author Inderjeet Singh
*/
public interface JsonPostDeserializer<T> {
/** This method is called by Gson after the object has been deserialized from Json. */
public void postDeserialize(T object);
}
================================================
FILE: extras/src/main/java/com/google/gson/typeadapters/PostConstructAdapterFactory.java
================================================
/*
* Copyright (C) 2016 Gson Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gson.typeadapters;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.annotation.PostConstruct;
public class PostConstructAdapterFactory implements TypeAdapterFactory {
// copied from https://gist.github.com/swankjesse/20df26adaf639ed7fd160f145a0b661a
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
for (Class<?> t = type.getRawType();
(t != Object.class) && (t.getSuperclass() != null);
t = t.getSuperclass()) {
for (Method m : t.getDeclaredMethods()) {
if (m.isAnnotationPresent(PostConstruct.class)) {
m.setAccessible(true);
TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
return new PostConstructAdapter<>(delegate, m);
}
}
}
return null;
}
static final class PostConstructAdapter<T> extends TypeAdapter<T> {
private final TypeAdapter<T> delegate;
private final Method method;
public PostConstructAdapter(TypeAdapter<T> delegate, Method method) {
this.delegate = delegate;
this.method = method;
}
@Override
public T read(JsonReader in) throws IOException {
T result = delegate.read(in);
if (result != null) {
try {
method.invoke(result);
} catch (IllegalAccessException e) {
throw new AssertionError(e);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
}
throw new RuntimeException(e.getCause());
}
}
return result;
}
@Override
public void write(JsonWriter out, T value) throws IOException {
delegate.write(out, value);
}
}
}
================================================
FILE: extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java
================================================
/*
* Copyright (C) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gson.typeadapters;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Adapts values whose runtime type may differ from their declaration type. This is necessary when a
* field's type is not the same type that GSON should create when deserializing that field. For
* example, consider these types:
*
* <pre>{@code
* abstract class Shape {
* int x;
* int y;
* }
* class Circle extends Shape {
* int radius;
* }
* class Rectangle extends Shape {
* int width;
* int height;
* }
* class Diamond extends Shape {
* int width;
* int height;
* }
* class Drawing {
* Shape bottomShape;
* Shape topShape;
* }
* }</pre>
*
* <p>Without additional type information, the serialized JSON is ambiguous. Is the bottom shape in
* this drawing a rectangle or a diamond?
*
* <pre>{@code
* {
* "bottomShape": {
* "width": 10,
* "height": 5,
* "x": 0,
* "y": 0
* },
* "topShape": {
* "radius": 2,
* "x": 4,
* "y": 1
* }
* }
* }</pre>
*
* This class addresses this problem by adding type information to the serialized JSON and honoring
* that type information when the JSON is deserialized:
*
* <pre>{@code
* {
* "bottomShape": {
* "type": "Diamond",
* "width": 10,
* "height": 5,
* "x": 0,
* "y": 0
* },
* "topShape": {
* "type": "Circle",
* "radius": 2,
* "x": 4,
* "y": 1
* }
* }
* }</pre>
*
* Both the type field name ({@code "type"}) and the type labels ({@code "Rectangle"}) are
* configurable.
*
* <h2>Registering Types</h2>
*
* Create a {@code RuntimeTypeAdapterFactory} by passing the base type and type field name to the
* {@link #of} factory method. If you don't supply an explicit type field name, {@code "type"} will
* be used.
*
* <pre>{@code
* RuntimeTypeAdapterFactory<Shape> shapeAdapterFactory
* = RuntimeTypeAdapterFactory.of(Shape.class, "type");
* }</pre>
*
* Next register all of your subtypes. Every subtype must be explicitly registered. This protects
* your application from injection attacks. If you don't supply an explicit type label, the type's
* simple name will be used.
*
* <pre>{@code
* shapeAdapterFactory.registerSubtype(Rectangle.class, "Rectangle");
* shapeAdapterFactory.registerSubtype(Circle.class, "Circle");
* shapeAdapterFactory.registerSubtype(Diamond.class, "Diamond");
* }</pre>
*
* Finally, register the type adapter factory in your application's GSON builder:
*
* <pre>{@code
* Gson gson = new GsonBuilder()
* .registerTypeAdapterFactory(shapeAdapterFactory)
* .create();
* }</pre>
*
* Like {@code GsonBuilder}, this API supports chaining:
*
* <pre>{@code
* RuntimeTypeAdapterFactory<Shape> shapeAdapterFactory = RuntimeTypeAdapterFactory.of(Shape.class)
* .registerSubtype(Rectangle.class)
* .registerSubtype(Circle.class)
* .registerSubtype(Diamond.class);
* }</pre>
*
* <h2>Serialization and deserialization</h2>
*
* In order to serialize and deserialize a polymorphic object, you must specify the base type
* explicitly.
*
* <pre>{@code
* Diamond diamond = new Diamond();
* String json = gson.toJson(diamond, Shape.class);
* }</pre>
*
* And then:
*
* <pre>{@code
* Shape shape = gson.fromJson(json, Shape.class);
* }</pre>
*/
public final class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory {
private final Class<?> baseType;
private final String typeFieldName;
private final Map<String, Class<?>> labelToSubtype = new LinkedHashMap<>();
private final Map<Class<?>, String> subtypeToLabel = new LinkedHashMap<>();
private final boolean maintainType;
private boolean recognizeSubtypes;
private RuntimeTypeAdapterFactory(Class<?> baseType, String typeFieldName, boolean maintainType) {
if (typeFieldName == null || baseType == null) {
throw new NullPointerException();
}
this.baseType = baseType;
this.typeFieldName = typeFieldName;
this.maintainType = maintainType;
}
/**
* Creates a new runtime type adapter for {@code baseType} using {@code typeFieldName} as the type
* field name. Type field names are case sensitive.
*
* @param maintainType true if the type field should be included in deserialized objects
*/
public static <T> RuntimeTypeAdapterFactory<T> of(
Class<T> baseType, String typeFieldName, boolean maintainType) {
return new RuntimeTypeAdapterFactory<>(baseType, typeFieldName, maintainType);
}
/**
* Creates a new runtime type adapter for {@code baseType} using {@code typeFieldName} as the type
* field name. Type field names are case sensitive.
*/
public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType, String typeFieldName) {
return new RuntimeTypeAdapterFactory<>(baseType, typeFieldName, false);
}
/**
* Creates a new runtime type adapter for {@code baseType} using {@code "type"} as the type field
* name.
*/
public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType) {
return new RuntimeTypeAdapterFactory<>(baseType, "type", false);
}
/**
* Ensures that this factory will handle not just the given {@code baseType}, but any subtype of
* that type.
*/
@CanIgnoreReturnValue
public RuntimeTypeAdapterFactory<T> recognizeSubtypes() {
this.recognizeSubtypes = true;
return this;
}
/**
* Registers {@code type} identified by {@code label}. Labels are case sensitive.
*
* @throws IllegalArgumentException if either {@code type} or {@code label} have already been
* registered on this type adapter.
*/
@CanIgnoreReturnValue
public RuntimeTypeAdapterFactory<T> registerSubtype(Class<? extends T> type, String label) {
if (type == null || label == null) {
throw new NullPointerException();
}
if (subtypeToLabel.containsKey(type) || labelToSubtype.containsKey(label)) {
throw new IllegalArgumentException("types and labels must be unique");
}
labelToSubtype.put(label, type);
subtypeToLabel.put(type, label);
return this;
}
/**
* Registers {@code type} identified by its {@link Class#getSimpleName simple name}. Labels are
* case sensitive.
*
* @throws IllegalArgumentException if either {@code type} or its simple name have already been
* registered on this type adapter.
*/
@CanIgnoreReturnValue
public RuntimeTypeAdapterFactory<T> registerSubtype(Class<? extends T> type) {
return registerSubtype(type, type.getSimpleName());
}
@Override
public <R> TypeAdapter<R> create(Gson gson, TypeToken<R> type) {
if (type == null) {
return null;
}
Class<?> rawType = type.getRawType();
boolean handle =
recognizeSubtypes ? baseType.isAssignableFrom(rawType) : baseType.equals(rawType);
if (!handle) {
return null;
}
TypeAdapter<JsonElement> jsonElementAdapter = gson.getAdapter(JsonElement.class);
Map<String, TypeAdapter<?>> labelToDelegate = new LinkedHashMap<>();
Map<Class<?>, TypeAdapter<?>> subtypeToDelegate = new LinkedHashMap<>();
for (Map.Entry<String, Class<?>> entry : labelToSubtype.entrySet()) {
TypeAdapter<?> delegate = gson.getDelegateAdapter(this, TypeToken.get(entry.getValue()));
labelToDelegate.put(entry.getKey(), delegate);
subtypeToDelegate.put(entry.getValue(), delegate);
}
return new TypeAdapter<R>() {
@Override
public R read(JsonReader in) throws IOException {
JsonElement jsonElement = jsonElementAdapter.read(in);
JsonElement labelJsonElement;
if (maintainType) {
labelJsonElement = jsonElement.getAsJsonObject().get(typeFieldName);
} else {
labelJsonElement = jsonElement.getAsJsonObject().remove(typeFieldName);
}
if (labelJsonElement == null) {
throw new JsonParseException(
"cannot deserialize "
+ baseType
+ " because it does not define a field named "
+ typeFieldName);
}
String label = labelJsonElement.getAsString();
@SuppressWarnings("unchecked") // registration requires that subtype extends T
TypeAdapter<R> delegate = (TypeAdapter<R>) labelToDelegate.get(label);
if (delegate == null) {
throw new JsonParseException(
"cannot deserialize "
+ baseType
+ " subtype named "
+ label
+ "; did you forget to register a subtype?");
}
return delegate.fromJsonTree(jsonElement);
}
@Override
public void write(JsonWriter out, R value) throws IOException {
Class<?> srcType = value.getClass();
String label = subtypeToLabel.get(srcType);
@SuppressWarnings("unchecked") // registration requires that subtype extends T
TypeAdapter<R> delegate = (TypeAdapter<R>) subtypeToDelegate.get(srcType);
if (delegate == null) {
throw new JsonParseException(
"cannot serialize " + srcType.getName() + "; did you forget to register a subtype?");
}
JsonObject jsonObject = delegate.toJsonTree(value).getAsJsonObject();
if (maintainType) {
jsonElementAdapter.write(out, jsonObject);
return;
}
JsonObject clone = new JsonObject();
if (jsonObject.has(typeFieldName)) {
throw new JsonParseException(
"cannot serialize "
+ srcType.getName()
+ " because it already defines a field named "
+ typeFieldName);
}
clone.add(typeFieldName, new JsonPrimitive(label));
for (Map.Entry<String, JsonElement> e : jsonObject.entrySet()) {
clone.add(e.getKey(), e.getValue());
}
jsonElementAdapter.write(out, clone);
}
}.nullSafe();
}
}
================================================
FILE: extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java
================================================
/*
* Copyright (C) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gson.typeadapters;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
public final class UtcDateTypeAdapter extends TypeAdapter<Date> {
private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("UTC");
@Override
public void write(JsonWriter out, Date date) throws IOException {
if (date == null) {
out.nullValue();
} else {
String value = format(date, true, UTC_TIME_ZONE);
out.value(value);
}
}
@Override
public Date read(JsonReader in) throws IOException {
try {
if (in.peek().equals(JsonToken.NULL)) {
in.nextNull();
return null;
} else {
String date = in.nextString();
// Instead of using iso8601Format.parse(value), we use Jackson's date parsing
// This is because Android doesn't support XXX because it is JDK 1.6
return parse(date, new ParsePosition(0));
}
} catch (ParseException e) {
throw new JsonParseException(e);
}
}
// Date parsing code from Jackson databind ISO8601Utils.java
// https://github.com/FasterXML/jackson-databind/blob/2.8/src/main/java/com/fasterxml/jackson/databind/util/ISO8601Utils.java
private static final String GMT_ID = "GMT";
/**
* Format date into yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]
*
* @param date the date to format
* @param millis true to include millis precision otherwise false
* @param tz timezone to use for the formatting (GMT will produce 'Z')
* @return the date formatted as yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]
*/
private static String format(Date date, boolean millis, TimeZone tz) {
Calendar calendar = new GregorianCalendar(tz, Locale.US);
calendar.setTime(date);
// estimate capacity of buffer as close as we can (yeah, that's pedantic ;)
int capacity = "yyyy-MM-ddThh:mm:ss".length();
capacity += millis ? ".sss".length() : 0;
capacity += tz.getRawOffset() == 0 ? "Z".length() : "+hh:mm".length();
StringBuilder formatted = new StringBuilder(capacity);
padInt(formatted, calendar.get(Calendar.YEAR), "yyyy".length());
formatted.append('-');
padInt(formatted, calendar.get(Calendar.MONTH) + 1, "MM".length());
formatted.append('-');
padInt(formatted, calendar.get(Calendar.DAY_OF_MONTH), "dd".length());
formatted.append('T');
padInt(formatted, calendar.get(Calendar.HOUR_OF_DAY), "hh".length());
formatted.append(':');
padInt(formatted, calendar.get(Calendar.MINUTE), "mm".length());
formatted.append(':');
padInt(formatted, calendar.get(Calendar.SECOND), "ss".length());
if (millis) {
formatted.append('.');
padInt(formatted, calendar.get(Calendar.MILLISECOND), "sss".length());
}
int offset = tz.getOffset(calendar.getTimeInMillis());
if (offset != 0) {
int hours = Math.abs((offset / (60 * 1000)) / 60);
int minutes = Math.abs((offset / (60 * 1000)) % 60);
formatted.append(offset < 0 ? '-' : '+');
padInt(formatted, hours, "hh".length());
formatted.append(':');
padInt(formatted, minutes, "mm".length());
} else {
formatted.append('Z');
}
return formatted.toString();
}
/**
* Zero pad a number to a specified length
*
* @param buffer buffer to use for padding
* @param value the integer value to pad if necessary.
* @param length the length of the string we should zero pad
*/
private static void padInt(StringBuilder buffer, int value, int length) {
String strValue = Integer.toString(value);
for (int i = length - strValue.length(); i > 0; i--) {
buffer.append('0');
}
buffer.append(strValue);
}
/**
* Parse a date from ISO-8601 formatted string. It expects a format
* [yyyy-MM-dd|yyyyMMdd][T(hh:mm[:ss[.sss]]|hhmm[ss[.sss]])]?[Z|[+-]hh:mm]]
*
* @param date ISO string to parse in the appropriate format.
* @param pos The position to start parsing from, updated to where parsing stopped.
* @return the parsed date
* @throws ParseException if the date is not in the appropriate format
*/
private static Date parse(String date, ParsePosition pos) throws ParseException {
Exception fail = null;
try {
int offset = pos.getIndex();
// extract year
int year = parseInt(date, offset, offset += 4);
if (checkOffset(date, offset, '-')) {
offset += 1;
}
// extract month
int month = parseInt(date, offset, offset += 2);
if (checkOffset(date, offset, '-')) {
offset += 1;
}
// extract day
int day = parseInt(date, offset, offset += 2);
// default time value
int hour = 0;
int minutes = 0;
int seconds = 0;
// always use 0 otherwise returned date will include millis of current time
int milliseconds = 0;
if (checkOffset(date, offset, 'T')) {
// extract hours, minutes, seconds and milliseconds
hour = parseInt(date, offset += 1, offset += 2);
if (checkOffset(date, offset, ':')) {
offset += 1;
}
minutes = parseInt(date, offset, offset += 2);
if (checkOffset(date, offset, ':')) {
offset += 1;
}
// second and milliseconds can be optional
if (date.length() > offset) {
char c = date.charAt(offset);
if (c != 'Z' && c != '+' && c != '-') {
seconds = parseInt(date, offset, offset += 2);
// milliseconds can be optional in the format
if (checkOffset(date, offset, '.')) {
milliseconds = parseInt(date, offset += 1, offset += 3);
}
}
}
}
// extract timezone
String timezoneId;
if (date.length() <= offset) {
throw new IllegalArgumentException("No time zone indicator");
}
char timezoneIndicator = date.charAt(offset);
if (timezoneIndicator == '+' || timezoneIndicator == '-') {
String timezoneOffset = date.substring(offset);
timezoneId = GMT_ID + timezoneOffset;
offset += timezoneOffset.length();
} else if (timezoneIndicator == 'Z') {
timezoneId = GMT_ID;
offset += 1;
} else {
throw new IndexOutOfBoundsException("Invalid time zone indicator " + timezoneIndicator);
}
TimeZone timezone = TimeZone.getTimeZone(timezoneId);
if (!timezone.getID().equals(timezoneId)) {
throw new IndexOutOfBoundsException();
}
Calendar calendar = new GregorianCalendar(timezone);
calendar.setLenient(false);
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.DAY_OF_MONTH, day);
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minutes);
calendar.set(Calendar.SECOND, seconds);
calendar.set(Calendar.MILLISECOND, milliseconds);
pos.setIndex(offset);
return calendar.getTime();
// If we get a ParseException it'll already have the right message/offset.
// Other exception types can convert here.
} catch (IndexOutOfBoundsException | IllegalArgumentException e) {
fail = e;
}
String input = (date == null) ? null : ("'" + date + "'");
throw new ParseException(
"Failed to parse date [" + input + "]: " + fail.getMessage(), pos.getIndex());
}
/**
* Check if the expected character exist at the given offset in the value.
*
* @param value the string to check at the specified offset
* @param offset the offset to look for the expected character
* @param expected the expected character
* @return true if the expected character exist at the given offset
*/
private static boolean checkOffset(String value, int offset, char expected) {
return (offset < value.length()) && (value.charAt(offset) == expected);
}
/**
* Parse an integer located between 2 given offsets in a string
*
* @param value the string to parse
* @param beginIndex the start index for the integer in the string
* @param endIndex the end index for the integer in the string
* @return the int
* @throws NumberFormatException if the value is not a number
*/
private static int parseInt(String value, int beginIndex, int endIndex)
throws NumberFormatException {
if (beginIndex < 0 || endIndex > value.length() || beginIndex > endIndex) {
throw new NumberFormatException(value);
}
// use same logic as in Integer.parseInt() but less generic we're not supporting negative values
int i = beginIndex;
int result = 0;
int digit;
if (i < endIndex) {
digit = Character.digit(value.charAt(i++), 10);
if (digit < 0) {
throw new NumberFormatException("Invalid number: " + value);
}
result = -digit;
}
while (i < endIndex) {
digit = Character.digit(value.charAt(i++), 10);
if (digit < 0) {
throw new NumberFormatException("Invalid number: " + value);
}
result *= 10;
result -= digit;
}
return -result;
}
}
================================================
FILE: extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java
================================================
/*
* Copyright (C) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gson.interceptors;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import com.google.gson.TypeAdapter;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.junit.Before;
import org.junit.Test;
/**
* Unit tests for {@link Intercept} and {@link JsonPostDeserializer}.
*
* @author Inderjeet Singh
*/
public final class InterceptorTest {
private Gson gson;
@Before
public void setUp() throws Exception {
this.gson =
new GsonBuilder()
.registerTypeAdapterFactory(new InterceptorFactory())
.enableComplexMapKeySerialization()
.create();
}
@Test
public void testExceptionsPropagated() {
var e = assertThrows(JsonParseException.class, () -> gson.fromJson("{}", User.class));
assertThat(e).hasMessageThat().isEqualTo("name and password are required fields.");
}
@Test
public void testTopLevelClass() {
User user = gson.fromJson("{name:'bob',password:'pwd'}", User.class);
assertThat(user.email).isEqualTo(User.DEFAULT_EMAIL);
}
@Test
public void testList() {
List<User> list =
gson.fromJson("[{name:'bob',password:'pwd'}]", new TypeToken<List<User>>() {}.getType());
User user = list.get(0);
assertThat(user.email).isEqualTo(User.DEFAULT_EMAIL);
}
@Test
public void testCollection() {
Collection<User> list =
gson.fromJson(
"[{name:'bob',password:'pwd'}]", new TypeToken<Collection<User>>() {}.getType());
User user = list.iterator().next();
assertThat(user.email).isEqualTo(User.DEFAULT_EMAIL);
}
@Test
public void testMapKeyAndValues() {
Type mapType = new TypeToken<Map<User, Address>>() {}.getType();
var e =
assertThrows(
JsonSyntaxException.class,
() -> gson.fromJson("[[{name:'bob',password:'pwd'},{}]]", mapType));
assertThat(e).hasMessageThat().isEqualTo("Address city, state and zip are required fields.");
Map<User, Address> map =
gson.fromJson(
"[[{name:'bob',password:'pwd'},{city:'Mountain View',state:'CA',zip:'94043'}]]",
mapType);
Entry<User, Address> entry = map.entrySet().iterator().next();
assertThat(entry.getKey().email).isEqualTo(User.DEFAULT_EMAIL);
assertThat(entry.getValue().firstLine).isEqualTo(Address.DEFAULT_FIRST_LINE);
}
@Test
public void testField() {
UserGroup userGroup = gson.fromJson("{user:{name:'bob',password:'pwd'}}", UserGroup.class);
assertThat(userGroup.user.email).isEqualTo(User.DEFAULT_EMAIL);
}
@Test
public void testCustomTypeAdapter() {
Gson gson =
new GsonBuilder()
.registerTypeAdapter(
User.class,
new TypeAdapter<User>() {
@Override
public void write(JsonWriter out, User value) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public User read(JsonReader in) throws IOException {
in.beginObject();
assertThat(in.nextName()).isEqualTo("name");
String name = in.nextString();
assertThat(in.nextName()).isEqualTo("password");
String password = in.nextString();
in.endObject();
return new User(name, password);
}
})
.registerTypeAdapterFactory(new InterceptorFactory())
.create();
UserGroup userGroup = gson.fromJson("{user:{name:'bob',password:'pwd'}}", UserGroup.class);
assertThat(userGroup.user.email).isEqualTo(User.DEFAULT_EMAIL);
}
@Test
public void testDirectInvocationOfTypeAdapter() throws Exception {
TypeAdapter<UserGroup> adapter = gson.getAdapter(UserGroup.class);
UserGroup userGroup = adapter.fromJson("{\"user\":{\"name\":\"bob\",\"password\":\"pwd\"}}");
assertThat(userGroup.user.email).isEqualTo(User.DEFAULT_EMAIL);
}
@SuppressWarnings("unused")
private static final class UserGroup {
User user;
String city;
}
@Intercept(postDeserialize = UserValidator.class)
@SuppressWarnings("unused")
private static final class User {
static final String DEFAULT_EMAIL = "invalid@invalid.com";
String name;
String password;
String email;
Address address;
User(String name, String password) {
this.name = name;
this.password = password;
}
}
public static final class UserValidator implements JsonPostDeserializer<User> {
@Override
public void postDeserialize(User user) {
if (user.name == null || user.password == null) {
throw new JsonSyntaxException("name and password are required fields.");
}
if (user.email == null) {
user.email = User.DEFAULT_EMAIL;
}
}
}
@Intercept(postDeserialize = AddressValidator.class)
@SuppressWarnings("unused")
private static final class Address {
static final String DEFAULT_FIRST_LINE = "unknown";
String firstLine;
String secondLine;
String city;
String state;
String zip;
}
public static final class AddressValidator implements JsonPostDeserializer<Address> {
@Override
public void postDeserialize(Address address) {
if (address.city == null || address.state == null || address.zip == null) {
throw new JsonSyntaxException("Address city, state and zip are required fields.");
}
if (address.firstLine == null) {
address.firstLine = Address.DEFAULT_FIRST_LINE;
}
}
}
}
================================================
FILE: extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java
================================================
/*
* Copyright (C) 2016 Gson Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gson.typeadapters;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import javax.annotation.PostConstruct;
import org.junit.Test;
public class PostConstructAdapterFactoryTest {
@Test
public void test() throws Exception {
Gson gson =
new GsonBuilder().registerTypeAdapterFactory(new PostConstructAdapterFactory()).create();
Sandwich unused =
gson.fromJson("{\"bread\": \"white\", \"cheese\": \"cheddar\"}", Sandwich.class);
var e =
assertThrows(
IllegalArgumentException.class,
() ->
gson.fromJson(
"{\"bread\": \"cheesey bread\", \"cheese\": \"swiss\"}", Sandwich.class));
assertThat(e).hasMessageThat().isEqualTo("too cheesey");
}
@Test
public void testList() {
MultipleSandwiches sandwiches =
new MultipleSandwiches(
Arrays.asList(new Sandwich("white", "cheddar"), new Sandwich("whole wheat", "swiss")));
Gson gson =
new GsonBuilder().registerTypeAdapterFactory(new PostConstructAdapterFactory()).create();
// Throws NullPointerException without the fix in https://github.com/google/gson/pull/1103
String json = gson.toJson(sandwiches);
assertThat(json)
.isEqualTo(
"{\"sandwiches\":[{\"bread\":\"white\",\"cheese\":\"cheddar\"},"
+ "{\"bread\":\"whole wheat\",\"cheese\":\"swiss\"}]}");
MultipleSandwiches sandwichesFromJson = gson.fromJson(json, MultipleSandwiches.class);
assertThat(sandwichesFromJson).isEqualTo(sandwiches);
}
@SuppressWarnings({"overrides", "EqualsHashCode"}) // for missing hashCode() override
static class Sandwich {
public String bread;
public String cheese;
public Sandwich(String bread, String cheese) {
this.bread = bread;
this.cheese = cheese;
}
@PostConstruct
private void validate() {
if (bread.equals("cheesey bread") && cheese != null) {
throw new IllegalArgumentException("too cheesey");
}
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Sandwich)) {
return false;
}
Sandwich other = (Sandwich) o;
return Objects.equals(this.bread, other.bread) && Objects.equals(this.cheese, other.cheese);
}
}
@SuppressWarnings({"overrides", "EqualsHashCode"}) // for missing hashCode() override
static class MultipleSandwiches {
public List<Sandwich> sandwiches;
public MultipleSandwiches(List<Sandwich> sandwiches) {
this.sandwiches = sandwiches;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof MultipleSandwiches)) {
return false;
}
MultipleSandwiches other = (MultipleSandwiches) o;
return Objects.equals(this.sandwiches, other.sandwiches);
}
}
}
================================================
FILE: extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java
================================================
/*
* Copyright (C) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gson.typeadapters;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import org.junit.Test;
public final class RuntimeTypeAdapterFactoryTest {
@Test
public void testRuntimeTypeAdapter() {
RuntimeTypeAdapterFactory<BillingInstrument> rta =
RuntimeTypeAdapterFactory.of(BillingInstrument.class).registerSubtype(CreditCard.class);
Gson gson = new GsonBuilder().registerTypeAdapterFactory(rta).create();
CreditCard original = new CreditCard("Jesse", 234);
assertThat(gson.toJson(original, BillingInstrument.class))
.isEqualTo("{\"type\":\"CreditCard\",\"cvv\":234,\"ownerName\":\"Jesse\"}");
BillingInstrument deserialized =
gson.fromJson("{type:'CreditCard',cvv:234,ownerName:'Jesse'}", BillingInstrument.class);
assertThat(deserialized.ownerName).isEqualTo("Jesse");
assertThat(deserialized).isInstanceOf(CreditCard.class);
}
@Test
public void testRuntimeTypeAdapterRecognizeSubtypes() {
// We don't have an explicit factory for CreditCard.class, but we do have one for
// BillingInstrument.class that has recognizeSubtypes(). So it should recognize CreditCard, and
// when we call gson.toJson(original) below, without an explicit type, it should be invoked.
RuntimeTypeAdapterFactory<BillingInstrument> rta =
RuntimeTypeAdapterFactory.of(BillingInstrument.class)
.recognizeSubtypes()
.registerSubtype(CreditCard.class);
Gson gson = new GsonBuilder().registerTypeAdapterFactory(rta).create();
CreditCard original = new CreditCard("Jesse", 234);
assertThat(gson.toJson(original))
.isEqualTo("{\"type\":\"CreditCard\",\"cvv\":234,\"ownerName\":\"Jesse\"}");
BillingInstrument deserialized =
gson.fromJson("{type:'CreditCard',cvv:234,ownerName:'Jesse'}", BillingInstrument.class);
assertThat(deserialized.ownerName).isEqualTo("Jesse");
assertThat(deserialized).isInstanceOf(CreditCard.class);
}
@Test
public void testRuntimeTypeIsBaseType() {
TypeAdapterFactory rta =
RuntimeTypeAdapterFactory.of(BillingInstrument.class)
.registerSubtype(BillingInstrument.class);
Gson gson = new GsonBuilder().registerTypeAdapterFactory(rta).create();
BillingInstrument original = new BillingInstrument("Jesse");
assertThat(gson.toJson(original, BillingInstrument.class))
.isEqualTo("{\"type\":\"BillingInstrument\",\"ownerName\":\"Jesse\"}");
BillingInstrument deserialized =
gson.fromJson("{type:'BillingInstrument',ownerName:'Jesse'}", BillingInstrument.class);
assertThat(deserialized.
gitextract_4tdusv9e/
├── .git-blame-ignore-revs
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ ├── config.yml
│ │ └── feature_request.md
│ ├── dependabot.yml
│ ├── pull_request_template.md
│ └── workflows/
│ ├── build.yml
│ ├── check-android-compatibility.yml
│ ├── check-api-compatibility.yml
│ ├── cifuzz.yml
│ ├── codeql-analysis.yml
│ └── scorecard.yml
├── .gitignore
├── .mvn/
│ └── jvm.config
├── CHANGELOG.md
├── GsonDesignDocument.md
├── LICENSE
├── README.md
├── ReleaseProcess.md
├── Troubleshooting.md
├── UserGuide.md
├── extras/
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ ├── main/
│ │ └── java/
│ │ └── com/
│ │ └── google/
│ │ └── gson/
│ │ ├── extras/
│ │ │ └── examples/
│ │ │ └── rawcollections/
│ │ │ └── RawCollectionsExample.java
│ │ ├── interceptors/
│ │ │ ├── Intercept.java
│ │ │ ├── InterceptorFactory.java
│ │ │ └── JsonPostDeserializer.java
│ │ └── typeadapters/
│ │ ├── PostConstructAdapterFactory.java
│ │ ├── RuntimeTypeAdapterFactory.java
│ │ └── UtcDateTypeAdapter.java
│ └── test/
│ └── java/
│ └── com/
│ └── google/
│ └── gson/
│ ├── interceptors/
│ │ └── InterceptorTest.java
│ └── typeadapters/
│ ├── PostConstructAdapterFactoryTest.java
│ ├── RuntimeTypeAdapterFactoryTest.java
│ └── UtcDateTypeAdapterTest.java
├── gson/
│ ├── LICENSE
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ ├── main/
│ │ ├── java/
│ │ │ ├── com/
│ │ │ │ └── google/
│ │ │ │ └── gson/
│ │ │ │ ├── ExclusionStrategy.java
│ │ │ │ ├── FieldAttributes.java
│ │ │ │ ├── FieldNamingPolicy.java
│ │ │ │ ├── FieldNamingStrategy.java
│ │ │ │ ├── FormattingStyle.java
│ │ │ │ ├── Gson.java
│ │ │ │ ├── GsonBuilder.java
│ │ │ │ ├── InstanceCreator.java
│ │ │ │ ├── JsonArray.java
│ │ │ │ ├── JsonDeserializationContext.java
│ │ │ │ ├── JsonDeserializer.java
│ │ │ │ ├── JsonElement.java
│ │ │ │ ├── JsonIOException.java
│ │ │ │ ├── JsonNull.java
│ │ │ │ ├── JsonObject.java
│ │ │ │ ├── JsonParseException.java
│ │ │ │ ├── JsonParser.java
│ │ │ │ ├── JsonPrimitive.java
│ │ │ │ ├── JsonSerializationContext.java
│ │ │ │ ├── JsonSerializer.java
│ │ │ │ ├── JsonStreamParser.java
│ │ │ │ ├── JsonSyntaxException.java
│ │ │ │ ├── LongSerializationPolicy.java
│ │ │ │ ├── ReflectionAccessFilter.java
│ │ │ │ ├── Strictness.java
│ │ │ │ ├── ToNumberPolicy.java
│ │ │ │ ├── ToNumberStrategy.java
│ │ │ │ ├── TypeAdapter.java
│ │ │ │ ├── TypeAdapterFactory.java
│ │ │ │ ├── annotations/
│ │ │ │ │ ├── Expose.java
│ │ │ │ │ ├── JsonAdapter.java
│ │ │ │ │ ├── SerializedName.java
│ │ │ │ │ ├── Since.java
│ │ │ │ │ ├── Until.java
│ │ │ │ │ └── package-info.java
│ │ │ │ ├── internal/
│ │ │ │ │ ├── ConstructorConstructor.java
│ │ │ │ │ ├── Excluder.java
│ │ │ │ │ ├── GsonTypes.java
│ │ │ │ │ ├── JavaVersion.java
│ │ │ │ │ ├── JsonReaderInternalAccess.java
│ │ │ │ │ ├── LazilyParsedNumber.java
│ │ │ │ │ ├── LinkedTreeMap.java
│ │ │ │ │ ├── NonNullElementWrapperList.java
│ │ │ │ │ ├── NumberLimits.java
│ │ │ │ │ ├── ObjectConstructor.java
│ │ │ │ │ ├── PreJava9DateFormatProvider.java
│ │ │ │ │ ├── Primitives.java
│ │ │ │ │ ├── ReflectionAccessFilterHelper.java
│ │ │ │ │ ├── Streams.java
│ │ │ │ │ ├── TroubleshootingGuide.java
│ │ │ │ │ ├── UnsafeAllocator.java
│ │ │ │ │ ├── bind/
│ │ │ │ │ │ ├── ArrayTypeAdapter.java
│ │ │ │ │ │ ├── CollectionTypeAdapterFactory.java
│ │ │ │ │ │ ├── DefaultDateTypeAdapter.java
│ │ │ │ │ │ ├── EnumTypeAdapter.java
│ │ │ │ │ │ ├── IgnoreJRERequirement.java
│ │ │ │ │ │ ├── JavaTimeTypeAdapters.java
│ │ │ │ │ │ ├── JsonAdapterAnnotationTypeAdapterFactory.java
│ │ │ │ │ │ ├── JsonElementTypeAdapter.java
│ │ │ │ │ │ ├── JsonTreeReader.java
│ │ │ │ │ │ ├── JsonTreeWriter.java
│ │ │ │ │ │ ├── MapTypeAdapterFactory.java
│ │ │ │ │ │ ├── NumberTypeAdapter.java
│ │ │ │ │ │ ├── ObjectTypeAdapter.java
│ │ │ │ │ │ ├── ReflectiveTypeAdapterFactory.java
│ │ │ │ │ │ ├── SerializationDelegatingTypeAdapter.java
│ │ │ │ │ │ ├── TreeTypeAdapter.java
│ │ │ │ │ │ ├── TypeAdapterRuntimeTypeWrapper.java
│ │ │ │ │ │ ├── TypeAdapters.java
│ │ │ │ │ │ └── util/
│ │ │ │ │ │ └── ISO8601Utils.java
│ │ │ │ │ ├── package-info.java
│ │ │ │ │ ├── reflect/
│ │ │ │ │ │ └── ReflectionHelper.java
│ │ │ │ │ └── sql/
│ │ │ │ │ ├── SqlDateTypeAdapter.java
│ │ │ │ │ ├── SqlTimeTypeAdapter.java
│ │ │ │ │ ├── SqlTimestampTypeAdapter.java
│ │ │ │ │ └── SqlTypesSupport.java
│ │ │ │ ├── package-info.java
│ │ │ │ ├── reflect/
│ │ │ │ │ ├── TypeToken.java
│ │ │ │ │ └── package-info.java
│ │ │ │ └── stream/
│ │ │ │ ├── JsonReader.java
│ │ │ │ ├── JsonScope.java
│ │ │ │ ├── JsonToken.java
│ │ │ │ ├── JsonWriter.java
│ │ │ │ ├── MalformedJsonException.java
│ │ │ │ └── package-info.java
│ │ │ └── module-info.java
│ │ ├── java-templates/
│ │ │ └── com/
│ │ │ └── google/
│ │ │ └── gson/
│ │ │ └── internal/
│ │ │ └── GsonBuildConfig.java
│ │ └── resources/
│ │ └── META-INF/
│ │ └── proguard/
│ │ └── gson.pro
│ └── test/
│ ├── java/
│ │ └── com/
│ │ └── google/
│ │ └── gson/
│ │ ├── CommentsTest.java
│ │ ├── DefaultInetAddressTypeAdapterTest.java
│ │ ├── DefaultMapJsonSerializerTest.java
│ │ ├── ExposeAnnotationExclusionStrategyTest.java
│ │ ├── FieldAttributesTest.java
│ │ ├── FieldNamingPolicyTest.java
│ │ ├── GenericArrayTypeTest.java
│ │ ├── GsonBuilderTest.java
│ │ ├── GsonTest.java
│ │ ├── GsonTypeAdapterTest.java
│ │ ├── InnerClassExclusionStrategyTest.java
│ │ ├── JavaSerializationTest.java
│ │ ├── JsonArrayAsListSuiteTest.java
│ │ ├── JsonArrayAsListTest.java
│ │ ├── JsonArrayTest.java
│ │ ├── JsonNullTest.java
│ │ ├── JsonObjectAsMapSuiteTest.java
│ │ ├── JsonObjectAsMapTest.java
│ │ ├── JsonObjectTest.java
│ │ ├── JsonParserParameterizedTest.java
│ │ ├── JsonParserTest.java
│ │ ├── JsonPrimitiveTest.java
│ │ ├── JsonStreamParserTest.java
│ │ ├── LongSerializationPolicyTest.java
│ │ ├── MixedStreamTest.java
│ │ ├── ObjectTypeAdapterParameterizedTest.java
│ │ ├── ObjectTypeAdapterTest.java
│ │ ├── OverrideCoreTypeAdaptersTest.java
│ │ ├── ParameterizedTypeFixtures.java
│ │ ├── ParameterizedTypeTest.java
│ │ ├── PrimitiveTypeAdapter.java
│ │ ├── SubsetTest.java
│ │ ├── ToNumberPolicyTest.java
│ │ ├── TypeAdapterTest.java
│ │ ├── VersionExclusionStrategyTest.java
│ │ ├── common/
│ │ │ ├── MoreAsserts.java
│ │ │ └── TestTypes.java
│ │ ├── functional/
│ │ │ ├── ArrayTest.java
│ │ │ ├── CircularReferenceTest.java
│ │ │ ├── CollectionTest.java
│ │ │ ├── ConcurrencyTest.java
│ │ │ ├── CustomDeserializerTest.java
│ │ │ ├── CustomSerializerTest.java
│ │ │ ├── CustomTypeAdaptersTest.java
│ │ │ ├── DefaultTypeAdaptersTest.java
│ │ │ ├── DelegateTypeAdapterTest.java
│ │ │ ├── EnumTest.java
│ │ │ ├── EnumWithObfuscatedTest.java
│ │ │ ├── EscapingTest.java
│ │ │ ├── ExclusionStrategyFunctionalTest.java
│ │ │ ├── ExposeFieldsTest.java
│ │ │ ├── FieldExclusionTest.java
│ │ │ ├── FieldNamingTest.java
│ │ │ ├── FormattingStyleTest.java
│ │ │ ├── GsonVersionDiagnosticsTest.java
│ │ │ ├── InheritanceTest.java
│ │ │ ├── InstanceCreatorTest.java
│ │ │ ├── InterfaceTest.java
│ │ │ ├── InternationalizationTest.java
│ │ │ ├── Java17RecordTest.java
│ │ │ ├── JavaUtilConcurrentAtomicTest.java
│ │ │ ├── JavaUtilTest.java
│ │ │ ├── JsonAdapterAnnotationOnClassesTest.java
│ │ │ ├── JsonAdapterAnnotationOnFieldsTest.java
│ │ │ ├── JsonAdapterSerializerDeserializerTest.java
│ │ │ ├── JsonParserTest.java
│ │ │ ├── JsonTreeTest.java
│ │ │ ├── LeniencyTest.java
│ │ │ ├── MapAsArrayTypeAdapterTest.java
│ │ │ ├── MapTest.java
│ │ │ ├── MoreSpecificTypeSerializationTest.java
│ │ │ ├── NamingPolicyTest.java
│ │ │ ├── NullObjectAndFieldTest.java
│ │ │ ├── NumberLimitsTest.java
│ │ │ ├── ObjectTest.java
│ │ │ ├── ParameterizedTypesTest.java
│ │ │ ├── PrettyPrintingTest.java
│ │ │ ├── PrimitiveCharacterTest.java
│ │ │ ├── PrimitiveTest.java
│ │ │ ├── PrintFormattingTest.java
│ │ │ ├── RawSerializationTest.java
│ │ │ ├── ReadersWritersTest.java
│ │ │ ├── ReflectionAccessFilterTest.java
│ │ │ ├── ReflectionAccessTest.java
│ │ │ ├── ReusedTypeVariablesFullyResolveTest.java
│ │ │ ├── RuntimeTypeAdapterFactoryFunctionalTest.java
│ │ │ ├── SecurityTest.java
│ │ │ ├── SerializedNameTest.java
│ │ │ ├── StreamingTypeAdaptersTest.java
│ │ │ ├── StringTest.java
│ │ │ ├── ToNumberPolicyFunctionalTest.java
│ │ │ ├── TreeTypeAdaptersTest.java
│ │ │ ├── TypeAdapterPrecedenceTest.java
│ │ │ ├── TypeAdapterRuntimeTypeWrapperTest.java
│ │ │ ├── TypeHierarchyAdapterTest.java
│ │ │ ├── TypeVariableTest.java
│ │ │ ├── UncategorizedTest.java
│ │ │ └── VersioningTest.java
│ │ ├── integration/
│ │ │ └── OSGiManifestIT.java
│ │ ├── internal/
│ │ │ ├── ConstructorConstructorTest.java
│ │ │ ├── GsonBuildConfigTest.java
│ │ │ ├── GsonTypesTest.java
│ │ │ ├── JavaVersionTest.java
│ │ │ ├── LazilyParsedNumberTest.java
│ │ │ ├── LinkedTreeMapSuiteTest.java
│ │ │ ├── LinkedTreeMapTest.java
│ │ │ ├── StreamsTest.java
│ │ │ ├── UnsafeAllocatorInstantiationTest.java
│ │ │ ├── bind/
│ │ │ │ ├── DefaultDateTypeAdapterTest.java
│ │ │ │ ├── Java17ReflectiveTypeAdapterFactoryTest.java
│ │ │ │ ├── JsonElementReaderTest.java
│ │ │ │ ├── JsonTreeReaderTest.java
│ │ │ │ ├── JsonTreeWriterTest.java
│ │ │ │ ├── RecursiveTypesResolveTest.java
│ │ │ │ └── util/
│ │ │ │ └── ISO8601UtilsTest.java
│ │ │ ├── reflect/
│ │ │ │ └── Java17ReflectionHelperTest.java
│ │ │ └── sql/
│ │ │ ├── SqlTypesGsonTest.java
│ │ │ └── SqlTypesSupportTest.java
│ │ ├── metrics/
│ │ │ └── PerformanceTest.java
│ │ ├── reflect/
│ │ │ └── TypeTokenTest.java
│ │ └── stream/
│ │ ├── JsonReaderPathTest.java
│ │ ├── JsonReaderTest.java
│ │ └── JsonWriterTest.java
│ └── resources/
│ └── testcases-proguard.conf
├── metrics/
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ └── main/
│ └── java/
│ └── com/
│ └── google/
│ └── gson/
│ └── metrics/
│ ├── BagOfPrimitives.java
│ ├── BagOfPrimitivesDeserializationBenchmark.java
│ ├── CollectionsDeserializationBenchmark.java
│ ├── NonUploadingCaliperRunner.java
│ ├── ParseBenchmark.java
│ └── SerializationBenchmark.java
├── pom.xml
├── proto/
│ ├── .gitignore
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ ├── main/
│ │ └── java/
│ │ └── com/
│ │ └── google/
│ │ └── gson/
│ │ └── protobuf/
│ │ └── ProtoTypeAdapter.java
│ └── test/
│ ├── java/
│ │ └── com/
│ │ └── google/
│ │ └── gson/
│ │ └── protobuf/
│ │ └── functional/
│ │ ├── ProtosWithAnnotationsAndJsonNamesTest.java
│ │ ├── ProtosWithAnnotationsTest.java
│ │ ├── ProtosWithComplexAndRepeatedFieldsTest.java
│ │ └── ProtosWithPrimitiveTypesTest.java
│ └── protobuf/
│ ├── annotations.proto
│ └── bag.proto
├── test-graal-native-image/
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ └── test/
│ ├── java/
│ │ └── com/
│ │ └── google/
│ │ └── gson/
│ │ └── native_test/
│ │ ├── Java17RecordReflectionTest.java
│ │ └── ReflectionTest.java
│ └── resources/
│ └── META-INF/
│ └── native-image/
│ └── reflect-config.json
├── test-jpms/
│ ├── README.md
│ ├── pom.xml
│ └── src/
│ ├── main/
│ │ └── java/
│ │ └── module-info.java
│ └── test/
│ └── java/
│ ├── com/
│ │ └── google/
│ │ └── gson/
│ │ └── jpms_test/
│ │ ├── ExportedPackagesTest.java
│ │ ├── ModuleTest.java
│ │ ├── ReflectionInaccessibleTest.java
│ │ └── opened/
│ │ └── ReflectionTest.java
│ └── module-info.java
└── test-shrinker/
├── README.md
├── common.pro
├── pom.xml
├── proguard.pro
├── r8.pro
└── src/
├── main/
│ └── java/
│ └── com/
│ └── example/
│ ├── ClassWithAdapter.java
│ ├── ClassWithExposeAnnotation.java
│ ├── ClassWithHasArgsConstructor.java
│ ├── ClassWithJsonAdapterAnnotation.java
│ ├── ClassWithNamedFields.java
│ ├── ClassWithNoArgsConstructor.java
│ ├── ClassWithSerializedName.java
│ ├── ClassWithUnreferencedHasArgsConstructor.java
│ ├── ClassWithUnreferencedNoArgsConstructor.java
│ ├── ClassWithVersionAnnotations.java
│ ├── EnumClass.java
│ ├── EnumClassWithSerializedName.java
│ ├── GenericClasses.java
│ ├── InterfaceWithImplementation.java
│ ├── Main.java
│ ├── NoSerializedNameMain.java
│ ├── TestExecutor.java
│ └── UnusedClass.java
└── test/
└── java/
└── com/
└── google/
└── gson/
└── it/
└── ShrinkingIT.java
Showing preview only (282K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (3814 symbols across 244 files)
FILE: extras/src/main/java/com/google/gson/extras/examples/rawcollections/RawCollectionsExample.java
class RawCollectionsExample (line 24) | @SuppressWarnings({"PrivateConstructorForUtilityClass", "SystemOut"})
class Event (line 26) | static class Event {
method Event (line 30) | private Event(String name, String source) {
method toString (line 35) | @Override
method main (line 41) | @SuppressWarnings({"unchecked", "rawtypes"})
FILE: extras/src/main/java/com/google/gson/interceptors/InterceptorFactory.java
class InterceptorFactory (line 28) | public final class InterceptorFactory implements TypeAdapterFactory {
method create (line 29) | @Override
class InterceptorAdapter (line 40) | static class InterceptorAdapter<T> extends TypeAdapter<T> {
method InterceptorAdapter (line 44) | @SuppressWarnings("unchecked") // ?
method write (line 54) | @Override
method read (line 59) | @Override
FILE: extras/src/main/java/com/google/gson/interceptors/JsonPostDeserializer.java
type JsonPostDeserializer (line 27) | public interface JsonPostDeserializer<T> {
method postDeserialize (line 30) | public void postDeserialize(T object);
FILE: extras/src/main/java/com/google/gson/typeadapters/PostConstructAdapterFactory.java
class PostConstructAdapterFactory (line 30) | public class PostConstructAdapterFactory implements TypeAdapterFactory {
method create (line 32) | @Override
class PostConstructAdapter (line 48) | static final class PostConstructAdapter<T> extends TypeAdapter<T> {
method PostConstructAdapter (line 52) | public PostConstructAdapter(TypeAdapter<T> delegate, Method method) {
method read (line 57) | @Override
method write (line 75) | @Override
FILE: extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java
class RuntimeTypeAdapterFactory (line 158) | public final class RuntimeTypeAdapterFactory<T> implements TypeAdapterFa...
method RuntimeTypeAdapterFactory (line 166) | private RuntimeTypeAdapterFactory(Class<?> baseType, String typeFieldN...
method of (line 181) | public static <T> RuntimeTypeAdapterFactory<T> of(
method of (line 190) | public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType, S...
method of (line 198) | public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType) {
method recognizeSubtypes (line 206) | @CanIgnoreReturnValue
method registerSubtype (line 218) | @CanIgnoreReturnValue
method registerSubtype (line 238) | @CanIgnoreReturnValue
method create (line 243) | @Override
FILE: extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java
class UtcDateTypeAdapter (line 33) | public final class UtcDateTypeAdapter extends TypeAdapter<Date> {
method write (line 36) | @Override
method read (line 46) | @Override
method format (line 75) | private static String format(Date date, boolean millis, TimeZone tz) {
method padInt (line 123) | private static void padInt(StringBuilder buffer, int value, int length) {
method parse (line 140) | private static Date parse(String date, ParsePosition pos) throws Parse...
method checkOffset (line 242) | private static boolean checkOffset(String value, int offset, char expe...
method parseInt (line 255) | private static int parseInt(String value, int beginIndex, int endIndex)
FILE: extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java
class InterceptorTest (line 43) | public final class InterceptorTest {
method setUp (line 47) | @Before
method testExceptionsPropagated (line 56) | @Test
method testTopLevelClass (line 62) | @Test
method testList (line 68) | @Test
method testCollection (line 76) | @Test
method testMapKeyAndValues (line 85) | @Test
method testField (line 103) | @Test
method testCustomTypeAdapter (line 109) | @Test
method testDirectInvocationOfTypeAdapter (line 138) | @Test
class UserGroup (line 145) | @SuppressWarnings("unused")
class User (line 151) | @Intercept(postDeserialize = UserValidator.class)
method User (line 160) | User(String name, String password) {
class UserValidator (line 166) | public static final class UserValidator implements JsonPostDeserialize...
method postDeserialize (line 167) | @Override
class Address (line 178) | @Intercept(postDeserialize = AddressValidator.class)
class AddressValidator (line 189) | public static final class AddressValidator implements JsonPostDeserial...
method postDeserialize (line 190) | @Override
FILE: extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java
class PostConstructAdapterFactoryTest (line 30) | public class PostConstructAdapterFactoryTest {
method test (line 31) | @Test
method testList (line 47) | @Test
class Sandwich (line 67) | @SuppressWarnings({"overrides", "EqualsHashCode"}) // for missing hash...
method Sandwich (line 72) | public Sandwich(String bread, String cheese) {
method validate (line 77) | @PostConstruct
method equals (line 84) | @Override
class MultipleSandwiches (line 98) | @SuppressWarnings({"overrides", "EqualsHashCode"}) // for missing hash...
method MultipleSandwiches (line 102) | public MultipleSandwiches(List<Sandwich> sandwiches) {
method equals (line 106) | @Override
FILE: extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java
class RuntimeTypeAdapterFactoryTest (line 28) | public final class RuntimeTypeAdapterFactoryTest {
method testRuntimeTypeAdapter (line 30) | @Test
method testRuntimeTypeAdapterRecognizeSubtypes (line 45) | @Test
method testRuntimeTypeIsBaseType (line 65) | @Test
method testNullBaseType (line 80) | @Test
method testNullTypeFieldName (line 85) | @Test
method testNullSubtype (line 92) | @Test
method testNullLabel (line 99) | @Test
method testDuplicateSubtype (line 106) | @Test
method testDuplicateLabel (line 117) | @Test
method testDeserializeMissingTypeField (line 128) | @Test
method testDeserializeMissingSubtype (line 145) | @Test
method testSerializeMissingSubtype (line 162) | @Test
method testSerializeCollidingTypeFieldName (line 179) | @Test
method testSerializeWrappedNullValue (line 197) | @Test
class BillingInstrumentWrapper (line 211) | static class BillingInstrumentWrapper {
method BillingInstrumentWrapper (line 214) | BillingInstrumentWrapper(BillingInstrument instrument) {
class BillingInstrument (line 219) | static class BillingInstrument {
method BillingInstrument (line 222) | BillingInstrument(String ownerName) {
class CreditCard (line 227) | static class CreditCard extends BillingInstrument {
method CreditCard (line 230) | CreditCard(String ownerName, int cvv) {
class BankTransfer (line 236) | static class BankTransfer extends BillingInstrument {
method BankTransfer (line 239) | BankTransfer(String ownerName, int bankAccount) {
FILE: extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java
class UtcDateTypeAdapterTest (line 32) | @SuppressWarnings("JavaUtilDate")
method testLocalTimeZone (line 37) | @Test
method testDifferentTimeZones (line 45) | @Test
method testUtcDatesOnJdkBefore1_7 (line 61) | @Test
method testUtcWithJdk7Default (line 69) | @Test
method testNullDateSerialization (line 82) | @Test
method testWellFormedParseException (line 88) | @Test
FILE: gson/src/main/java-templates/com/google/gson/internal/GsonBuildConfig.java
class GsonBuildConfig (line 25) | public final class GsonBuildConfig {
method GsonBuildConfig (line 31) | private GsonBuildConfig() {}
FILE: gson/src/main/java/com/google/gson/ExclusionStrategy.java
type ExclusionStrategy (line 94) | public interface ExclusionStrategy {
method shouldSkipField (line 102) | boolean shouldSkipField(FieldAttributes f);
method shouldSkipClass (line 110) | boolean shouldSkipClass(Class<?> clazz);
FILE: gson/src/main/java/com/google/gson/FieldAttributes.java
class FieldAttributes (line 35) | public final class FieldAttributes {
method FieldAttributes (line 43) | public FieldAttributes(Field f) {
method getDeclaringClass (line 52) | public Class<?> getDeclaringClass() {
method getName (line 61) | public String getName() {
method getDeclaredType (line 84) | public Type getDeclaredType() {
method getDeclaredClass (line 105) | public Class<?> getDeclaredClass() {
method getAnnotation (line 116) | public <T extends Annotation> T getAnnotation(Class<T> annotation) {
method getAnnotations (line 126) | public Collection<Annotation> getAnnotations() {
method hasModifier (line 141) | public boolean hasModifier(int modifier) {
method toString (line 145) | @Override
FILE: gson/src/main/java/com/google/gson/FieldNamingPolicy.java
type FieldNamingPolicy (line 31) | public enum FieldNamingPolicy implements FieldNamingStrategy {
method translateName (line 35) | @Override
method translateName (line 53) | @Override
method translateName (line 73) | @Override
method translateName (line 95) | @Override
method translateName (line 115) | @Override
method translateName (line 142) | @Override
method translateName (line 169) | @Override
method separateCamelCase (line 179) | static String separateCamelCase(String name, char separator) {
method upperCaseFirstLetter (line 192) | static String upperCaseFirstLetter(String s) {
FILE: gson/src/main/java/com/google/gson/FieldNamingStrategy.java
type FieldNamingStrategy (line 33) | public interface FieldNamingStrategy {
method translateName (line 42) | String translateName(Field f);
method alternateNames (line 52) | default List<String> alternateNames(Field f) {
FILE: gson/src/main/java/com/google/gson/FormattingStyle.java
class FormattingStyle (line 39) | public class FormattingStyle {
method FormattingStyle (line 66) | private FormattingStyle(String newline, String indent, boolean spaceAf...
method withNewline (line 95) | public FormattingStyle withNewline(String newline) {
method withIndent (line 108) | public FormattingStyle withIndent(String indent) {
method withSpaceAfterSeparators (line 124) | public FormattingStyle withSpaceAfterSeparators(boolean spaceAfterSepa...
method getNewline (line 134) | public String getNewline() {
method getIndent (line 144) | public String getIndent() {
method usesSpaceAfterSeparators (line 153) | public boolean usesSpaceAfterSeparators() {
FILE: gson/src/main/java/com/google/gson/Gson.java
class Gson (line 135) | public final class Gson {
method Gson (line 222) | public Gson() {
method Gson (line 226) | Gson(GsonBuilder builder) {
method newBuilder (line 266) | public GsonBuilder newBuilder() {
method excluder (line 274) | @Deprecated
method fieldNamingStrategy (line 284) | public FieldNamingStrategy fieldNamingStrategy() {
method serializeNulls (line 294) | public boolean serializeNulls() {
method htmlSafe (line 304) | public boolean htmlSafe() {
method getAdapter (line 319) | public <T> TypeAdapter<T> getAdapter(TypeToken<T> type) {
method getAdapter (line 386) | public <T> TypeAdapter<T> getAdapter(Class<T> type) {
method getDelegateAdapter (line 451) | public <T> TypeAdapter<T> getDelegateAdapter(TypeAdapterFactory skipPa...
method toJsonTree (line 496) | public JsonElement toJsonTree(Object src) {
method toJsonTree (line 521) | public JsonElement toJsonTree(Object src, Type typeOfSrc) {
method toJson (line 542) | public String toJson(Object src) {
method toJson (line 567) | public String toJson(Object src, Type typeOfSrc) {
method toJson (line 589) | public void toJson(Object src, Appendable writer) throws JsonIOExcepti...
method toJson (line 617) | public void toJson(Object src, Type typeOfSrc, Appendable writer) thro...
method toJson (line 647) | public void toJson(Object src, Type typeOfSrc, JsonWriter writer) thro...
method toJson (line 685) | public String toJson(JsonElement jsonElement) {
method toJson (line 699) | public void toJson(JsonElement jsonElement, Appendable writer) throws ...
method toJson (line 728) | public void toJson(JsonElement jsonElement, JsonWriter writer) throws ...
method newJsonWriter (line 774) | public JsonWriter newJsonWriter(Writer writer) throws IOException {
method newJsonReader (line 798) | public JsonReader newJsonReader(Reader reader) {
method fromJson (line 827) | public <T> T fromJson(String json, Class<T> classOfT) throws JsonSynta...
method fromJson (line 855) | @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
method fromJson (line 886) | public <T> T fromJson(String json, TypeToken<T> typeOfT) throws JsonSy...
method fromJson (line 917) | public <T> T fromJson(Reader json, Class<T> classOfT)
method fromJson (line 947) | @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
method fromJson (line 978) | public <T> T fromJson(Reader json, TypeToken<T> typeOfT)
method fromJson (line 1022) | @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
method fromJson (line 1064) | public <T> T fromJson(JsonReader reader, TypeToken<T> typeOfT)
method fromJson (line 1136) | public <T> T fromJson(JsonElement json, Class<T> classOfT) throws Json...
method fromJson (line 1162) | @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
method fromJson (line 1189) | public <T> T fromJson(JsonElement json, TypeToken<T> typeOfT) throws J...
method assertFullConsumption (line 1196) | private static void assertFullConsumption(Object obj, JsonReader reade...
class FutureTypeAdapter (line 1216) | static class FutureTypeAdapter<T> extends SerializationDelegatingTypeA...
method setDelegate (line 1219) | public void setDelegate(TypeAdapter<T> typeAdapter) {
method delegate (line 1226) | private TypeAdapter<T> delegate() {
method getSerializationDelegate (line 1239) | @Override
method read (line 1244) | @Override
method write (line 1249) | @Override
method toString (line 1255) | @Override
FILE: gson/src/main/java/com/google/gson/GsonBuilder.java
class GsonBuilder (line 92) | public final class GsonBuilder {
method GsonBuilder (line 157) | public GsonBuilder() {}
method GsonBuilder (line 165) | GsonBuilder(Gson gson) {
method setVersion (line 203) | @CanIgnoreReturnValue
method excludeFieldsWithModifiers (line 226) | @CanIgnoreReturnValue
method generateNonExecutableJson (line 241) | @CanIgnoreReturnValue
method excludeFieldsWithoutExposeAnnotation (line 257) | @CanIgnoreReturnValue
method serializeNulls (line 270) | @CanIgnoreReturnValue
method enableComplexMapKeySerialization (line 358) | @CanIgnoreReturnValue
method disableInnerClassSerialization (line 385) | @CanIgnoreReturnValue
method setLongSerializationPolicy (line 399) | @CanIgnoreReturnValue
method setFieldNamingPolicy (line 411) | @CanIgnoreReturnValue
method setFieldNamingStrategy (line 428) | @CanIgnoreReturnValue
method setObjectToNumberStrategy (line 442) | @CanIgnoreReturnValue
method setNumberToNumberStrategy (line 456) | @CanIgnoreReturnValue
method setExclusionStrategies (line 487) | @CanIgnoreReturnValue
method addSerializationExclusionStrategy (line 510) | @CanIgnoreReturnValue
method addDeserializationExclusionStrategy (line 531) | @CanIgnoreReturnValue
method setPrettyPrinting (line 547) | @CanIgnoreReturnValue
method setFormattingStyle (line 561) | @CanIgnoreReturnValue
method setLenient (line 577) | @Deprecated
method setStrictness (line 599) | @CanIgnoreReturnValue
method disableHtmlEscaping (line 612) | @CanIgnoreReturnValue
method setDateFormat (line 637) | @CanIgnoreReturnValue
method setDateFormat (line 671) | @Deprecated
method setDateFormat (line 695) | @CanIgnoreReturnValue
method checkDateFormatStyle (line 703) | private static int checkDateFormatStyle(int style) {
method registerTypeAdapter (line 738) | @CanIgnoreReturnValue
method hasNonOverridableAdapter (line 773) | private static boolean hasNonOverridableAdapter(Type type) {
method registerTypeAdapterFactory (line 794) | @CanIgnoreReturnValue
method registerTypeHierarchyAdapter (line 817) | @CanIgnoreReturnValue
method serializeSpecialFloatingPointValues (line 861) | @CanIgnoreReturnValue
method disableJdkUnsafe (line 882) | @CanIgnoreReturnValue
method addReflectionAccessFilter (line 908) | @CanIgnoreReturnValue
method create (line 921) | public Gson create() {
method createFactories (line 925) | List<TypeAdapterFactory> createFactories(
method newImmutableList (line 1004) | static <E> List<E> newImmutableList(Collection<E> collection) {
method doubleAdapter (line 1019) | private TypeAdapter<Number> doubleAdapter() {
method floatAdapter (line 1023) | private TypeAdapter<Number> floatAdapter() {
method addUserDefinedAdapters (line 1027) | private void addUserDefinedAdapters(List<TypeAdapterFactory> all) {
method addDateTypeAdapters (line 1042) | private void addDateTypeAdapters(List<TypeAdapterFactory> factories) {
FILE: gson/src/main/java/com/google/gson/InstanceCreator.java
type InstanceCreator (line 80) | public interface InstanceCreator<T> {
method createInstance (line 92) | T createInstance(Type type);
FILE: gson/src/main/java/com/google/gson/JsonArray.java
class JsonArray (line 42) | public final class JsonArray extends JsonElement implements Iterable<Jso...
method JsonArray (line 46) | @SuppressWarnings("deprecation") // superclass constructor
method JsonArray (line 58) | @SuppressWarnings("deprecation") // superclass constructor
method deepCopy (line 68) | @Override
method add (line 86) | public void add(Boolean bool) {
method add (line 96) | public void add(Character character) {
method add (line 106) | public void add(Number number) {
method add (line 116) | public void add(String string) {
method add (line 125) | public void add(JsonElement element) {
method addAll (line 137) | public void addAll(JsonArray array) {
method set (line 149) | @CanIgnoreReturnValue
method remove (line 162) | @CanIgnoreReturnValue
method remove (line 177) | @CanIgnoreReturnValue
method contains (line 189) | public boolean contains(JsonElement element) {
method size (line 198) | public int size() {
method isEmpty (line 208) | public boolean isEmpty() {
method iterator (line 218) | @Override
method get (line 231) | public JsonElement get(int i) {
method getAsSingleElement (line 235) | private JsonElement getAsSingleElement() {
method getAsNumber (line 251) | @Override
method getAsString (line 264) | @Override
method getAsDouble (line 277) | @Override
method getAsBigDecimal (line 291) | @Override
method getAsBigInteger (line 305) | @Override
method getAsFloat (line 318) | @Override
method getAsLong (line 331) | @Override
method getAsInt (line 344) | @Override
method getAsByte (line 357) | @Override
method getAsCharacter (line 372) | @Deprecated
method getAsShort (line 386) | @Override
method getAsBoolean (line 399) | @Override
method asList (line 415) | public List<JsonElement> asList() {
method equals (line 423) | @Override
method hashCode (line 432) | @Override
FILE: gson/src/main/java/com/google/gson/JsonDeserializationContext.java
type JsonDeserializationContext (line 28) | public interface JsonDeserializationContext {
method deserialize (line 42) | @SuppressWarnings("TypeParameterUnusedInFormals")
FILE: gson/src/main/java/com/google/gson/JsonDeserializer.java
type JsonDeserializer (line 76) | public interface JsonDeserializer<T> {
method deserialize (line 93) | T deserialize(JsonElement json, Type typeOfT, JsonDeserializationConte...
FILE: gson/src/main/java/com/google/gson/JsonElement.java
class JsonElement (line 96) | public abstract class JsonElement {
method JsonElement (line 102) | @Deprecated
method deepCopy (line 111) | public abstract JsonElement deepCopy();
method isJsonArray (line 118) | public boolean isJsonArray() {
method isJsonObject (line 127) | public boolean isJsonObject() {
method isJsonPrimitive (line 136) | public boolean isJsonPrimitive() {
method isJsonNull (line 146) | public boolean isJsonNull() {
method getAsJsonObject (line 159) | public JsonObject getAsJsonObject() {
method getAsJsonArray (line 174) | public JsonArray getAsJsonArray() {
method getAsJsonPrimitive (line 190) | public JsonPrimitive getAsJsonPrimitive() {
method getAsJsonNull (line 206) | @CanIgnoreReturnValue // When this method is used only to verify that ...
method getAsBoolean (line 223) | public boolean getAsBoolean() {
method getAsNumber (line 236) | public Number getAsNumber() {
method getAsString (line 249) | public String getAsString() {
method getAsDouble (line 263) | public double getAsDouble() {
method getAsFloat (line 277) | public float getAsFloat() {
method getAsLong (line 291) | public long getAsLong() {
method getAsInt (line 305) | public int getAsInt() {
method getAsByte (line 320) | public byte getAsByte() {
method getAsCharacter (line 336) | @Deprecated
method getAsBigDecimal (line 352) | public BigDecimal getAsBigDecimal() {
method getAsBigInteger (line 367) | public BigInteger getAsBigInteger() {
method getAsShort (line 381) | public short getAsShort() {
method toString (line 420) | @Override
FILE: gson/src/main/java/com/google/gson/JsonIOException.java
class JsonIOException (line 24) | @SuppressWarnings("MemberName") // class name is part of the public API
method JsonIOException (line 28) | public JsonIOException(String msg) {
method JsonIOException (line 32) | public JsonIOException(String msg, Throwable cause) {
method JsonIOException (line 42) | public JsonIOException(Throwable cause) {
FILE: gson/src/main/java/com/google/gson/JsonNull.java
class JsonNull (line 26) | public final class JsonNull extends JsonElement {
method JsonNull (line 39) | @Deprecated
method deepCopy (line 49) | @Override
method hashCode (line 55) | @Override
method equals (line 61) | @Override
FILE: gson/src/main/java/com/google/gson/JsonObject.java
class JsonObject (line 40) | public final class JsonObject extends JsonElement {
method JsonObject (line 44) | @SuppressWarnings("deprecation") // superclass constructor
method deepCopy (line 52) | @Override
method add (line 69) | public void add(String property, JsonElement value) {
method remove (line 81) | @CanIgnoreReturnValue
method addProperty (line 93) | public void addProperty(String property, String value) {
method addProperty (line 104) | public void addProperty(String property, Number value) {
method addProperty (line 115) | public void addProperty(String property, Boolean value) {
method addProperty (line 126) | public void addProperty(String property, Character value) {
method entrySet (line 136) | public Set<Map.Entry<String, JsonElement>> entrySet() {
method keySet (line 146) | public Set<String> keySet() {
method size (line 156) | public int size() {
method isEmpty (line 166) | public boolean isEmpty() {
method has (line 176) | public boolean has(String memberName) {
method get (line 186) | public JsonElement get(String memberName) {
method getAsJsonPrimitive (line 198) | public JsonPrimitive getAsJsonPrimitive(String memberName) {
method getAsJsonArray (line 210) | public JsonArray getAsJsonArray(String memberName) {
method getAsJsonObject (line 222) | public JsonObject getAsJsonObject(String memberName) {
method asMap (line 237) | public Map<String, JsonElement> asMap() {
method equals (line 246) | @Override
method hashCode (line 255) | @Override
FILE: gson/src/main/java/com/google/gson/JsonParseException.java
class JsonParseException (line 32) | public class JsonParseException extends RuntimeException {
method JsonParseException (line 41) | public JsonParseException(String msg) {
method JsonParseException (line 51) | public JsonParseException(String msg, Throwable cause) {
method JsonParseException (line 61) | public JsonParseException(Throwable cause) {
FILE: gson/src/main/java/com/google/gson/JsonParser.java
class JsonParser (line 73) | public final class JsonParser {
method JsonParser (line 77) | @Deprecated
method parseString (line 91) | public static JsonElement parseString(String json) throws JsonSyntaxEx...
method parseReader (line 107) | public static JsonElement parseReader(Reader reader) throws JsonIOExce...
method parseReader (line 136) | public static JsonElement parseReader(JsonReader reader)
method parse (line 155) | @Deprecated
method parse (line 164) | @Deprecated
method parse (line 173) | @Deprecated
FILE: gson/src/main/java/com/google/gson/JsonPrimitive.java
class JsonPrimitive (line 35) | public final class JsonPrimitive extends JsonElement {
method JsonPrimitive (line 47) | @SuppressWarnings({"deprecation", "UnnecessaryBoxedVariable"})
method JsonPrimitive (line 57) | @SuppressWarnings("deprecation") // superclass constructor
method JsonPrimitive (line 67) | @SuppressWarnings("deprecation") // superclass constructor
method JsonPrimitive (line 81) | @SuppressWarnings({"deprecation", "UnnecessaryBoxedVariable"})
method deepCopy (line 93) | @Override
method isBoolean (line 103) | public boolean isBoolean() {
method getAsBoolean (line 113) | @Override
method isNumber (line 127) | public boolean isNumber() {
method getAsNumber (line 138) | @Override
method isString (line 153) | public boolean isString() {
method getAsString (line 158) | @Override
method getAsDouble (line 173) | @Override
method getAsBigDecimal (line 181) | @Override
method getAsBigInteger (line 191) | @Override
method getAsFloat (line 203) | @Override
method getAsLong (line 214) | @Override
method getAsShort (line 222) | @Override
method getAsInt (line 230) | @Override
method getAsByte (line 238) | @Override
method getAsCharacter (line 248) | @Deprecated
method hashCode (line 260) | @Override
method equals (line 281) | @Override
method isIntegral (line 317) | private static boolean isIntegral(JsonPrimitive primitive) {
FILE: gson/src/main/java/com/google/gson/JsonSerializationContext.java
type JsonSerializationContext (line 28) | public interface JsonSerializationContext {
method serialize (line 36) | JsonElement serialize(Object src);
method serialize (line 48) | JsonElement serialize(Object src, Type typeOfSrc);
FILE: gson/src/main/java/com/google/gson/JsonSerializer.java
type JsonSerializer (line 74) | public interface JsonSerializer<T> {
method serialize (line 90) | JsonElement serialize(T src, Type typeOfSrc, JsonSerializationContext ...
FILE: gson/src/main/java/com/google/gson/JsonStreamParser.java
class JsonStreamParser (line 51) | public final class JsonStreamParser implements Iterator<JsonElement> {
method JsonStreamParser (line 59) | public JsonStreamParser(String json) {
method JsonStreamParser (line 67) | public JsonStreamParser(Reader reader) {
method next (line 82) | @Override
method hasNext (line 102) | @Override
method remove (line 121) | @Override
FILE: gson/src/main/java/com/google/gson/JsonSyntaxException.java
class JsonSyntaxException (line 24) | public final class JsonSyntaxException extends JsonParseException {
method JsonSyntaxException (line 28) | public JsonSyntaxException(String msg) {
method JsonSyntaxException (line 32) | public JsonSyntaxException(String msg, Throwable cause) {
method JsonSyntaxException (line 42) | public JsonSyntaxException(Throwable cause) {
FILE: gson/src/main/java/com/google/gson/LongSerializationPolicy.java
type LongSerializationPolicy (line 28) | public enum LongSerializationPolicy {
method serialize (line 37) | @Override
method typeAdapter (line 45) | @Override
method serialize (line 58) | @Override
method typeAdapter (line 66) | @Override
method serialize (line 78) | public abstract JsonElement serialize(Long value);
method typeAdapter (line 82) | abstract TypeAdapter<Number> typeAdapter();
FILE: gson/src/main/java/com/google/gson/ReflectionAccessFilter.java
type ReflectionAccessFilter (line 45) | public interface ReflectionAccessFilter {
type FilterResult (line 51) | enum FilterResult {
method check (line 114) | @Override
method toString (line 121) | @Override
method check (line 145) | @Override
method toString (line 152) | @Override
method check (line 176) | @Override
method toString (line 183) | @Override
method check (line 208) | @Override
method toString (line 215) | @Override
method check (line 227) | FilterResult check(Class<?> rawClass);
FILE: gson/src/main/java/com/google/gson/Strictness.java
type Strictness (line 20) | public enum Strictness {
FILE: gson/src/main/java/com/google/gson/ToNumberPolicy.java
type ToNumberPolicy (line 34) | public enum ToNumberPolicy implements ToNumberStrategy {
method readNumber (line 41) | @Override
method readNumber (line 52) | @Override
method readNumber (line 68) | @Override
method parseAsDouble (line 82) | private Number parseAsDouble(String value, JsonReader in) throws IOExc...
method readNumber (line 102) | @Override
FILE: gson/src/main/java/com/google/gson/ToNumberStrategy.java
type ToNumberStrategy (line 60) | public interface ToNumberStrategy {
method readNumber (line 69) | Number readNumber(JsonReader in) throws IOException;
FILE: gson/src/main/java/com/google/gson/TypeAdapter.java
class TypeAdapter (line 121) | public abstract class TypeAdapter<T> {
method TypeAdapter (line 123) | public TypeAdapter() {}
method write (line 130) | public abstract void write(JsonWriter out, T value) throws IOException;
method toJson (line 142) | public final void toJson(Writer out, T value) throws IOException {
method toJson (line 159) | public final String toJson(T value) {
method toJsonTree (line 178) | public final JsonElement toJsonTree(T value) {
method read (line 194) | public abstract T read(JsonReader in) throws IOException;
method fromJson (line 210) | public final T fromJson(Reader in) throws IOException {
method fromJson (line 229) | public final T fromJson(String json) throws IOException {
method fromJsonTree (line 241) | public final T fromJsonTree(JsonElement jsonTree) {
method nullSafe (line 291) | public final TypeAdapter<T> nullSafe() {
class NullSafeTypeAdapter (line 298) | private final class NullSafeTypeAdapter extends TypeAdapter<T> {
method write (line 299) | @Override
method read (line 308) | @Override
method toString (line 317) | @Override
FILE: gson/src/main/java/com/google/gson/TypeAdapterFactory.java
type TypeAdapterFactory (line 164) | public interface TypeAdapterFactory {
method create (line 169) | <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type);
FILE: gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java
class ConstructorConstructor (line 45) | public final class ConstructorConstructor {
method ConstructorConstructor (line 50) | public ConstructorConstructor(
method checkInstantiable (line 66) | static String checkInstantiable(Class<?> c) {
method get (line 92) | public <T> ObjectConstructor<T> get(TypeToken<T> typeToken) {
method get (line 103) | public <T> ObjectConstructor<T> get(TypeToken<T> typeToken, boolean al...
method newSpecialCollectionConstructor (line 177) | private static <T> ObjectConstructor<T> newSpecialCollectionConstructor(
method newDefaultConstructor (line 217) | private static <T> ObjectConstructor<T> newDefaultConstructor(
method newDefaultImplementationConstructor (line 288) | private static <T> ObjectConstructor<T> newDefaultImplementationConstr...
method newCollectionConstructor (line 315) | private static ObjectConstructor<? extends Collection<?>> newCollectio...
method hasStringKeyType (line 339) | private static boolean hasStringKeyType(Type mapType) {
method newMapConstructor (line 352) | private static ObjectConstructor<? extends Map<?, Object>> newMapConst...
method newUnsafeAllocator (line 384) | private <T> ObjectConstructor<T> newUnsafeAllocator(Class<? super T> r...
method toString (line 420) | @Override
class ThrowingObjectConstructor (line 434) | private static final class ThrowingObjectConstructor<T> implements Obj...
method ThrowingObjectConstructor (line 437) | ThrowingObjectConstructor(String exceptionMessage) {
method construct (line 441) | @Override
class InstanceCreatorConstructor (line 451) | private static final class InstanceCreatorConstructor<T> implements Ob...
method InstanceCreatorConstructor (line 455) | InstanceCreatorConstructor(InstanceCreator<T> instanceCreator, Type ...
method construct (line 460) | @Override
FILE: gson/src/main/java/com/google/gson/internal/Excluder.java
class Excluder (line 49) | public final class Excluder implements TypeAdapterFactory, Cloneable {
method clone (line 60) | @Override
method withVersion (line 69) | public Excluder withVersion(double ignoreVersionsAfter) {
method withModifiers (line 75) | public Excluder withModifiers(int... modifiers) {
method disableInnerClassSerialization (line 84) | public Excluder disableInnerClassSerialization() {
method excludeFieldsWithoutExposeAnnotation (line 90) | public Excluder excludeFieldsWithoutExposeAnnotation() {
method withExclusionStrategy (line 96) | public Excluder withExclusionStrategy(
method create (line 110) | @Override
method excludeField (line 158) | public boolean excludeField(Field field, boolean serialize) {
method excludeClass (line 197) | public boolean excludeClass(Class<?> clazz, boolean serialize) {
method isInnerClass (line 234) | private static boolean isInnerClass(Class<?> clazz) {
method isValidVersion (line 238) | private boolean isValidVersion(Since since, Until until) {
method isValidSince (line 242) | private boolean isValidSince(Since annotation) {
method isValidUntil (line 250) | private boolean isValidUntil(Until annotation) {
FILE: gson/src/main/java/com/google/gson/internal/GsonTypes.java
class GsonTypes (line 44) | public final class GsonTypes {
method GsonTypes (line 47) | private GsonTypes() {
method newParameterizedTypeWithOwner (line 57) | public static ParameterizedType newParameterizedTypeWithOwner(
method arrayOf (line 67) | public static GenericArrayType arrayOf(Type componentType) {
method subtypeOf (line 77) | public static WildcardType subtypeOf(Type bound) {
method supertypeOf (line 91) | public static WildcardType supertypeOf(Type bound) {
method canonicalize (line 105) | public static Type canonicalize(Type type) {
method getRawType (line 129) | public static Class<?> getRawType(Type type) {
method equal (line 167) | private static boolean equal(Object a, Object b) {
method equals (line 172) | public static boolean equals(Type a, Type b) {
method typeToString (line 227) | public static String typeToString(Type type) {
method getGenericSupertype (line 236) | private static Type getGenericSupertype(Type context, Class<?> rawType...
method getSupertype (line 277) | private static Type getSupertype(Type context, Class<?> contextRawType...
method getArrayComponentType (line 299) | public static Type getArrayComponentType(Type array) {
method getCollectionElementType (line 310) | public static Type getCollectionElementType(Type context, Class<?> con...
method getMapKeyAndValueTypes (line 323) | public static Type[] getMapKeyAndValueTypes(Type context, Class<?> con...
method resolve (line 342) | public static Type resolve(Type context, Class<?> contextRawType, Type...
method resolve (line 347) | private static Type resolve(
method resolveTypeVariable (line 451) | private static Type resolveTypeVariable(
method indexOf (line 469) | private static int indexOf(Object[] array, Object toFind) {
method declaringClassOf (line 482) | private static Class<?> declaringClassOf(TypeVariable<?> typeVariable) {
method checkNotPrimitive (line 487) | static void checkNotPrimitive(Type type) {
method requiresOwnerType (line 500) | public static boolean requiresOwnerType(Type rawType) {
class ParameterizedTypeImpl (line 513) | private static final class ParameterizedTypeImpl implements Parameteri...
method ParameterizedTypeImpl (line 523) | ParameterizedTypeImpl(Type ownerType, Class<?> rawType, Type... type...
method getActualTypeArguments (line 540) | @Override
method getRawType (line 545) | @Override
method getOwnerType (line 550) | @Override
method equals (line 555) | @Override
method hashCodeOrZero (line 561) | private static int hashCodeOrZero(Object o) {
method hashCode (line 565) | @Override
method toString (line 570) | @Override
class GenericArrayTypeImpl (line 591) | private static final class GenericArrayTypeImpl implements GenericArra...
method GenericArrayTypeImpl (line 595) | GenericArrayTypeImpl(Type componentType) {
method getGenericComponentType (line 600) | @Override
method equals (line 605) | @Override
method hashCode (line 610) | @Override
method toString (line 615) | @Override
class WildcardTypeImpl (line 629) | private static final class WildcardTypeImpl implements WildcardType, S...
method WildcardTypeImpl (line 636) | WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds) {
method getUpperBounds (line 662) | @Override
method getLowerBounds (line 667) | @Override
method equals (line 672) | @Override
method hashCode (line 677) | @Override
method toString (line 683) | @Override
FILE: gson/src/main/java/com/google/gson/internal/JavaVersion.java
class JavaVersion (line 20) | public final class JavaVersion {
method determineMajorJavaVersion (line 28) | private static int determineMajorJavaVersion() {
method parseMajorJavaVersion (line 34) | static int parseMajorJavaVersion(String javaVersion) {
method parseDotted (line 46) | private static int parseDotted(String javaVersion) {
method extractBeginningInt (line 60) | private static int extractBeginningInt(String javaVersion) {
method getMajorJavaVersion (line 82) | public static int getMajorJavaVersion() {
method isJava9OrLater (line 92) | public static boolean isJava9OrLater() {
method JavaVersion (line 96) | private JavaVersion() {}
FILE: gson/src/main/java/com/google/gson/internal/JsonReaderInternalAccess.java
class JsonReaderInternalAccess (line 23) | public abstract class JsonReaderInternalAccess {
method promoteNameToValue (line 30) | public abstract void promoteNameToValue(JsonReader reader) throws IOEx...
FILE: gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java
class LazilyParsedNumber (line 29) | @SuppressWarnings("serial") // ignore warning about missing serialVersio...
method LazilyParsedNumber (line 36) | public LazilyParsedNumber(String value) {
method asBigDecimal (line 40) | private BigDecimal asBigDecimal() {
method intValue (line 44) | @Override
method longValue (line 57) | @Override
method floatValue (line 66) | @Override
method doubleValue (line 71) | @Override
method toString (line 76) | @Override
method writeReplace (line 85) | private Object writeReplace() throws ObjectStreamException {
method readObject (line 89) | private void readObject(ObjectInputStream in) throws IOException {
method hashCode (line 95) | @Override
method equals (line 100) | @Override
FILE: gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java
class LinkedTreeMap (line 43) | @SuppressWarnings("serial") // ignore warning about missing serialVersio...
method compare (line 48) | @Override
method LinkedTreeMap (line 67) | @SuppressWarnings("unchecked") // unsafe! this assumes K is comparable
method LinkedTreeMap (line 77) | @SuppressWarnings("unchecked") // unsafe! this assumes K is comparable
method LinkedTreeMap (line 91) | @SuppressWarnings({"unchecked", "rawtypes"})
method size (line 98) | @Override
method get (line 103) | @Override
method containsKey (line 109) | @Override
method put (line 114) | @CanIgnoreReturnValue
method clear (line 129) | @Override
method remove (line 140) | @Override
method find (line 151) | Node<K, V> find(K key, boolean create) {
method findByObject (line 213) | @SuppressWarnings("unchecked")
method findByEntry (line 230) | Node<K, V> findByEntry(Entry<?, ?> entry) {
method equal (line 236) | private static boolean equal(Object a, Object b) {
method removeInternal (line 245) | void removeInternal(Node<K, V> node, boolean unlink) {
method removeInternalByKey (line 304) | Node<K, V> removeInternalByKey(Object key) {
method replaceInParent (line 312) | @SuppressWarnings("ReferenceEquality")
method rebalance (line 338) | private void rebalance(Node<K, V> unbalanced, boolean insert) {
method rotateLeft (line 399) | private void rotateLeft(Node<K, V> root) {
method rotateRight (line 424) | private void rotateRight(Node<K, V> root) {
method entrySet (line 451) | @Override
method keySet (line 460) | @Override
class Node (line 469) | static final class Node<K, V> implements Entry<K, V> {
method Node (line 481) | Node(boolean allowNullValue) {
method Node (line 488) | Node(boolean allowNullValue, Node<K, V> parent, K key, Node<K, V> ne...
method getKey (line 499) | @Override
method getValue (line 504) | @Override
method setValue (line 509) | @Override
method equals (line 519) | @Override
method hashCode (line 529) | @Override
method toString (line 534) | @Override
method first (line 540) | public Node<K, V> first() {
method last (line 551) | public Node<K, V> last() {
class LinkedTreeMapIterator (line 562) | private abstract class LinkedTreeMapIterator<T> implements Iterator<T> {
method LinkedTreeMapIterator (line 567) | LinkedTreeMapIterator() {}
method hasNext (line 569) | @Override
method nextNode (line 575) | @SuppressWarnings("ReferenceEquality")
method remove (line 589) | @Override
class EntrySet (line 600) | class EntrySet extends AbstractSet<Entry<K, V>> {
method size (line 601) | @Override
method iterator (line 606) | @Override
method contains (line 616) | @Override
method remove (line 621) | @Override
method clear (line 635) | @Override
class KeySet (line 641) | final class KeySet extends AbstractSet<K> {
method size (line 642) | @Override
method iterator (line 647) | @Override
method contains (line 657) | @Override
method remove (line 662) | @Override
method clear (line 667) | @Override
method writeReplace (line 678) | private Object writeReplace() throws ObjectStreamException {
method readObject (line 682) | private void readObject(ObjectInputStream in) throws IOException {
FILE: gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java
class NonNullElementWrapperList (line 31) | public class NonNullElementWrapperList<E> extends AbstractList<E> implem...
method NonNullElementWrapperList (line 35) | @SuppressWarnings("NonApiType")
method get (line 40) | @Override
method size (line 45) | @Override
method nonNull (line 50) | private E nonNull(E element) {
method set (line 57) | @Override
method add (line 62) | @Override
method remove (line 67) | @Override
method clear (line 74) | @Override
method remove (line 79) | @SuppressWarnings("UngroupedOverloads") // this is intentionally ungro...
method removeAll (line 85) | @Override
method retainAll (line 90) | @Override
method contains (line 95) | @Override
method indexOf (line 100) | @Override
method lastIndexOf (line 105) | @Override
method toArray (line 110) | @Override
method toArray (line 115) | @Override
method equals (line 120) | @Override
method hashCode (line 125) | @Override
FILE: gson/src/main/java/com/google/gson/internal/NumberLimits.java
class NumberLimits (line 10) | public class NumberLimits {
method NumberLimits (line 11) | private NumberLimits() {}
method checkNumberStringLength (line 15) | private static void checkNumberStringLength(String s) {
method parseBigDecimal (line 21) | public static BigDecimal parseBigDecimal(String s) throws NumberFormat...
method parseBigInteger (line 32) | public static BigInteger parseBigInteger(String s) throws NumberFormat...
FILE: gson/src/main/java/com/google/gson/internal/ObjectConstructor.java
type ObjectConstructor (line 27) | public interface ObjectConstructor<T> {
method construct (line 30) | T construct();
FILE: gson/src/main/java/com/google/gson/internal/PreJava9DateFormatProvider.java
class PreJava9DateFormatProvider (line 23) | public class PreJava9DateFormatProvider {
method PreJava9DateFormatProvider (line 24) | private PreJava9DateFormatProvider() {}
method getUsDateTimeFormat (line 30) | public static DateFormat getUsDateTimeFormat(int dateStyle, int timeSt...
method getDatePartOfDateTimePattern (line 36) | private static String getDatePartOfDateTimePattern(int dateStyle) {
method getTimePartOfDateTimePattern (line 51) | private static String getTimePartOfDateTimePattern(int timeStyle) {
FILE: gson/src/main/java/com/google/gson/internal/Primitives.java
class Primitives (line 27) | public final class Primitives {
method Primitives (line 28) | private Primitives() {}
method isPrimitive (line 31) | public static boolean isPrimitive(Type type) {
method isWrapperType (line 41) | public static boolean isWrapperType(Type type) {
method wrap (line 63) | @SuppressWarnings({"unchecked", "MissingBraces"})
method unwrap (line 87) | @SuppressWarnings({"unchecked", "MissingBraces"})
FILE: gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java
class ReflectionAccessFilterHelper (line 26) | public class ReflectionAccessFilterHelper {
method ReflectionAccessFilterHelper (line 27) | private ReflectionAccessFilterHelper() {}
method isJavaType (line 33) | public static boolean isJavaType(Class<?> c) {
method isJavaType (line 37) | private static boolean isJavaType(String className) {
method isAndroidType (line 41) | public static boolean isAndroidType(Class<?> c) {
method isAndroidType (line 45) | private static boolean isAndroidType(String className) {
method isAnyPlatformType (line 51) | public static boolean isAnyPlatformType(Class<?> c) {
method getFilterResult (line 64) | public static FilterResult getFilterResult(
method canAccess (line 76) | public static boolean canAccess(AccessibleObject accessibleObject, Obj...
class AccessChecker (line 80) | private abstract static class AccessChecker {
method canAccess (line 92) | @Override
method canAccess (line 109) | @Override
method canAccess (line 119) | abstract boolean canAccess(AccessibleObject accessibleObject, Object...
FILE: gson/src/main/java/com/google/gson/internal/Streams.java
class Streams (line 37) | public final class Streams {
method Streams (line 38) | private Streams() {
method parse (line 43) | public static JsonElement parse(JsonReader reader) throws JsonParseExc...
method write (line 69) | public static void write(JsonElement element, JsonWriter writer) throw...
method writerForAppendable (line 73) | public static Writer writerForAppendable(Appendable appendable) {
class AppendableWriter (line 78) | private static final class AppendableWriter extends Writer {
method AppendableWriter (line 82) | AppendableWriter(Appendable appendable) {
method write (line 86) | @SuppressWarnings("UngroupedOverloads") // this is intentionally ung...
method flush (line 93) | @Override
method close (line 100) | @Override
method write (line 110) | @Override
method write (line 115) | @Override
method append (line 122) | @Override
method append (line 128) | @Override
class CurrentWrite (line 135) | private static class CurrentWrite implements CharSequence {
method setChars (line 139) | void setChars(char[] chars) {
method length (line 144) | @Override
method charAt (line 149) | @Override
method subSequence (line 154) | @Override
method toString (line 160) | @Override
FILE: gson/src/main/java/com/google/gson/internal/TroubleshootingGuide.java
class TroubleshootingGuide (line 3) | public class TroubleshootingGuide {
method TroubleshootingGuide (line 4) | private TroubleshootingGuide() {}
method createUrl (line 7) | public static String createUrl(String id) {
FILE: gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java
class UnsafeAllocator (line 30) | public abstract class UnsafeAllocator {
method newInstance (line 31) | public abstract <T> T newInstance(Class<T> c) throws Exception;
method assertInstantiable (line 38) | private static void assertInstantiable(Class<?> c) {
method create (line 48) | private static UnsafeAllocator create() {
FILE: gson/src/main/java/com/google/gson/internal/bind/ArrayTypeAdapter.java
class ArrayTypeAdapter (line 34) | public final class ArrayTypeAdapter<E> extends TypeAdapter<Object> {
method create (line 37) | @Override
method ArrayTypeAdapter (line 58) | public ArrayTypeAdapter(
method read (line 65) | @Override
method write (line 97) | @Override
FILE: gson/src/main/java/com/google/gson/internal/bind/CollectionTypeAdapterFactory.java
class CollectionTypeAdapterFactory (line 34) | public final class CollectionTypeAdapterFactory implements TypeAdapterFa...
method CollectionTypeAdapterFactory (line 37) | public CollectionTypeAdapterFactory(ConstructorConstructor constructor...
method create (line 41) | @Override
class Adapter (line 64) | private static final class Adapter<E> extends TypeAdapter<Collection<E...
method Adapter (line 68) | Adapter(
method read (line 74) | @Override
method write (line 91) | @Override
FILE: gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java
class DefaultDateTypeAdapter (line 55) | public final class DefaultDateTypeAdapter<T extends Date> extends TypeAd...
method create (line 66) | @SuppressWarnings("unchecked") // we use a runtime check to make sure ...
method toString (line 76) | @Override
class DateType (line 82) | public abstract static class DateType<T extends Date> {
method deserialize (line 85) | @Override
method DateType (line 93) | protected DateType(Class<T> dateClass) {
method deserialize (line 97) | protected abstract T deserialize(Date date);
method createFactory (line 99) | private TypeAdapterFactory createFactory(DefaultDateTypeAdapter<T> a...
method createAdapterFactory (line 103) | public final TypeAdapterFactory createAdapterFactory(String datePatt...
method createAdapterFactory (line 107) | public final TypeAdapterFactory createAdapterFactory(int dateStyle, ...
method DefaultDateTypeAdapter (line 120) | private DefaultDateTypeAdapter(DateType<T> dateType, String datePatter...
method DefaultDateTypeAdapter (line 128) | private DefaultDateTypeAdapter(DateType<T> dateType, int dateStyle, in...
method write (line 139) | @Override
method read (line 155) | @Override
method deserializeToDate (line 165) | private Date deserializeToDate(JsonReader in) throws IOException {
method toString (line 189) | @Override
FILE: gson/src/main/java/com/google/gson/internal/bind/EnumTypeAdapter.java
class EnumTypeAdapter (line 35) | class EnumTypeAdapter<T extends Enum<T>> extends TypeAdapter<T> {
method create (line 38) | @Override
method calculateHashMapCapacity (line 56) | private static int calculateHashMapCapacity(int numMappings) {
method EnumTypeAdapter (line 64) | private EnumTypeAdapter(Class<T> classOfT) {
method read (line 113) | @Override
method write (line 125) | @Override
FILE: gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java
class JavaTimeTypeAdapters (line 43) | @IgnoreJRERequirement // Protected by a reflective check
method get (line 46) | @Override
method create (line 53) | @Override
method integerValues (line 58) | @Override
method create (line 67) | @Override
method integerValues (line 72) | @Override
method create (line 81) | @Override
method integerValues (line 86) | @Override
method create (line 96) | @Override
method integerValues (line 105) | @Override
method localDateTime (line 113) | private static TypeAdapter<LocalDateTime> localDateTime(Gson gson) {
method create (line 155) | @Override
method integerValues (line 160) | @Override
method offsetDateTime (line 166) | private static TypeAdapter<OffsetDateTime> offsetDateTime(Gson gson) {
method offsetTime (line 207) | private static TypeAdapter<OffsetTime> offsetTime(Gson gson) {
method create (line 250) | @Override
method integerValues (line 255) | @Override
method create (line 263) | @Override
method integerValues (line 268) | @Override
method create (line 276) | @Override
method integerValues (line 281) | @Override
method read (line 294) | @Override
method write (line 324) | @Override
method zonedDateTime (line 340) | private static TypeAdapter<ZonedDateTime> zonedDateTime(Gson gson) {
method create (line 395) | @Override
method requireNonNullField (line 442) | private static <T> T requireNonNullField(T field, String fieldName, Js...
FILE: gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java
class JsonAdapterAnnotationTypeAdapterFactory (line 37) | public final class JsonAdapterAnnotationTypeAdapterFactory implements Ty...
class DummyTypeAdapterFactory (line 38) | private static class DummyTypeAdapterFactory implements TypeAdapterFac...
method create (line 39) | @Override
method JsonAdapterAnnotationTypeAdapterFactory (line 64) | public JsonAdapterAnnotationTypeAdapterFactory(ConstructorConstructor ...
method getAnnotation (line 70) | private static JsonAdapter getAnnotation(Class<?> rawType) {
method create (line 75) | @SuppressWarnings("unchecked")
method createAdapter (line 88) | private static Object createAdapter(
method putFactoryAndGetCurrent (line 99) | private TypeAdapterFactory putFactoryAndGetCurrent(Class<?> rawType, T...
method getTypeAdapter (line 105) | TypeAdapter<?> getTypeAdapter(
method isClassJsonAdapterFactory (line 168) | public boolean isClassJsonAdapterFactory(TypeToken<?> type, TypeAdapte...
FILE: gson/src/main/java/com/google/gson/internal/bind/JsonElementTypeAdapter.java
class JsonElementTypeAdapter (line 35) | public class JsonElementTypeAdapter extends TypeAdapter<JsonElement> {
method JsonElementTypeAdapter (line 38) | private JsonElementTypeAdapter() {}
method tryBeginNesting (line 44) | private JsonElement tryBeginNesting(JsonReader in, JsonToken peeked) t...
method readTerminal (line 58) | private JsonElement readTerminal(JsonReader in, JsonToken peeked) thro...
method read (line 76) | @Override
method write (line 138) | @Override
FILE: gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java
class JsonTreeReader (line 39) | public final class JsonTreeReader extends JsonReader {
method read (line 42) | @Override
method close (line 47) | @Override
method JsonTreeReader (line 76) | public JsonTreeReader(JsonElement element) {
method beginArray (line 81) | @Override
method endArray (line 89) | @Override
method beginObject (line 99) | @Override
method endObject (line 106) | @Override
method hasNext (line 117) | @Override
method peek (line 125) | @Override
method peekStack (line 170) | private Object peekStack() {
method popStack (line 174) | @CanIgnoreReturnValue
method expect (line 181) | private void expect(JsonToken expected) throws IOException {
method nextName (line 188) | private String nextName(boolean skipName) throws IOException {
method nextName (line 198) | @Override
method nextString (line 203) | @Override
method nextBoolean (line 217) | @Override
method nextNull (line 227) | @Override
method nextDouble (line 236) | @Override
method nextLong (line 254) | @Override
method nextInt (line 269) | @Override
method nextJsonElement (line 284) | JsonElement nextJsonElement() throws IOException {
method close (line 297) | @Override
method skipValue (line 303) | @Override
method toString (line 329) | @Override
method promoteNameToValue (line 334) | public void promoteNameToValue() throws IOException {
method push (line 342) | private void push(Object newTop) {
method getPath (line 352) | private String getPath(boolean usePreviousPath) {
method getPath (line 378) | @Override
method getPreviousPath (line 383) | @Override
method locationString (line 388) | private String locationString() {
FILE: gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java
class JsonTreeWriter (line 33) | public final class JsonTreeWriter extends JsonWriter {
method write (line 36) | @Override
method flush (line 41) | @Override
method close (line 46) | @Override
method JsonTreeWriter (line 64) | public JsonTreeWriter() {
method get (line 69) | public JsonElement get() {
method peek (line 76) | private JsonElement peek() {
method put (line 80) | private void put(JsonElement value) {
method beginArray (line 99) | @CanIgnoreReturnValue
method endArray (line 108) | @CanIgnoreReturnValue
method beginObject (line 122) | @CanIgnoreReturnValue
method endObject (line 131) | @CanIgnoreReturnValue
method name (line 145) | @CanIgnoreReturnValue
method value (line 160) | @CanIgnoreReturnValue
method value (line 170) | @CanIgnoreReturnValue
method value (line 177) | @CanIgnoreReturnValue
method value (line 187) | @CanIgnoreReturnValue
method value (line 197) | @CanIgnoreReturnValue
method value (line 207) | @CanIgnoreReturnValue
method value (line 214) | @CanIgnoreReturnValue
method nullValue (line 232) | @CanIgnoreReturnValue
method jsonValue (line 239) | @Override
method flush (line 244) | @Override
method close (line 247) | @Override
FILE: gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java
class MapTypeAdapterFactory (line 115) | public final class MapTypeAdapterFactory implements TypeAdapterFactory {
method MapTypeAdapterFactory (line 119) | public MapTypeAdapterFactory(
method create (line 125) | @Override
method getKeyAdapter (line 155) | private TypeAdapter<?> getKeyAdapter(Gson context, Type keyType) {
class Adapter (line 161) | private final class Adapter<K, V> extends TypeAdapter<Map<K, V>> {
method Adapter (line 166) | Adapter(
method read (line 175) | @Override
method write (line 214) | @Override
method keyToString (line 262) | private String keyToString(JsonElement keyElement) {
FILE: gson/src/main/java/com/google/gson/internal/bind/NumberTypeAdapter.java
class NumberTypeAdapter (line 32) | public final class NumberTypeAdapter extends TypeAdapter<Number> {
method NumberTypeAdapter (line 39) | private NumberTypeAdapter(ToNumberStrategy toNumberStrategy) {
method newFactory (line 43) | private static TypeAdapterFactory newFactory(ToNumberStrategy toNumber...
method getFactory (line 54) | public static TypeAdapterFactory getFactory(ToNumberStrategy toNumberS...
method read (line 62) | @Override
method write (line 78) | @Override
FILE: gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java
class ObjectTypeAdapter (line 40) | public final class ObjectTypeAdapter extends TypeAdapter<Object> {
method ObjectTypeAdapter (line 47) | private ObjectTypeAdapter(Gson gson, ToNumberStrategy toNumberStrategy) {
method newFactory (line 52) | private static TypeAdapterFactory newFactory(ToNumberStrategy toNumber...
method getFactory (line 65) | public static TypeAdapterFactory getFactory(ToNumberStrategy toNumberS...
method tryBeginNesting (line 77) | private Object tryBeginNesting(JsonReader in, JsonToken peeked) throws...
method readTerminal (line 91) | private Object readTerminal(JsonReader in, JsonToken peeked) throws IO...
method read (line 108) | @Override
method write (line 169) | @Override
FILE: gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java
class ReflectiveTypeAdapterFactory (line 60) | public final class ReflectiveTypeAdapterFactory implements TypeAdapterFa...
method ReflectiveTypeAdapterFactory (line 67) | public ReflectiveTypeAdapterFactory(
method includeField (line 80) | private boolean includeField(Field f, boolean serialize) {
method getFieldNames (line 85) | @SuppressWarnings("MixedMutabilityReturnType")
method create (line 109) | @Override
method checkAccessible (line 168) | private static <M extends AccessibleObject & Member> void checkAccessi...
method createBoundField (line 181) | private BoundField createBoundField(
class FieldsData (line 288) | private static class FieldsData {
method FieldsData (line 296) | FieldsData(Map<String, BoundField> deserializedFields, List<BoundFie...
method createDuplicateFieldException (line 302) | private static IllegalArgumentException createDuplicateFieldException(
method getBoundFields (line 317) | private FieldsData getBoundFields(
class BoundField (line 428) | abstract static class BoundField {
method BoundField (line 437) | protected BoundField(String serializedName, Field field) {
method write (line 444) | abstract void write(JsonWriter writer, Object source)
method readIntoArray (line 448) | abstract void readIntoArray(JsonReader reader, int index, Object[] t...
method readIntoField (line 455) | abstract void readIntoField(JsonReader reader, Object target)
class Adapter (line 474) | public abstract static class Adapter<T, A> extends TypeAdapter<T> {
method Adapter (line 477) | Adapter(FieldsData fieldsData) {
method write (line 481) | @Override
method read (line 499) | @Override
method createAccumulator (line 530) | abstract A createAccumulator();
method readField (line 536) | abstract void readField(A accumulator, JsonReader in, BoundField field)
method finalize (line 540) | abstract T finalize(A accumulator);
class FieldReflectionAdapter (line 543) | private static final class FieldReflectionAdapter<T> extends Adapter<T...
method FieldReflectionAdapter (line 546) | FieldReflectionAdapter(ObjectConstructor<T> constructor, FieldsData ...
method createAccumulator (line 551) | @Override
method readField (line 556) | @Override
method finalize (line 562) | @Override
class RecordAdapter (line 568) | private static final class RecordAdapter<T> extends Adapter<T, Object[...
method RecordAdapter (line 578) | RecordAdapter(Class<T> raw, FieldsData fieldsData, boolean blockInac...
method primitiveDefaults (line 605) | private static Map<Class<?>, Object> primitiveDefaults() {
method createAccumulator (line 618) | @Override
method readField (line 623) | @Override
method finalize (line 642) | @Override
FILE: gson/src/main/java/com/google/gson/internal/bind/SerializationDelegatingTypeAdapter.java
class SerializationDelegatingTypeAdapter (line 22) | public abstract class SerializationDelegatingTypeAdapter<T> extends Type...
method getSerializationDelegate (line 27) | public abstract TypeAdapter<T> getSerializationDelegate();
FILE: gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java
class TreeTypeAdapter (line 41) | public final class TreeTypeAdapter<T> extends SerializationDelegatingTyp...
method TreeTypeAdapter (line 62) | public TreeTypeAdapter(
method TreeTypeAdapter (line 77) | public TreeTypeAdapter(
method read (line 86) | @Override
method write (line 98) | @Override
method delegate (line 112) | private TypeAdapter<T> delegate() {
method getSerializationDelegate (line 126) | @Override
method newFactory (line 132) | public static TypeAdapterFactory newFactory(TypeToken<?> exactType, Ob...
method newFactoryWithMatchRawType (line 137) | public static TypeAdapterFactory newFactoryWithMatchRawType(
method newTypeHierarchyFactory (line 148) | public static TypeAdapterFactory newTypeHierarchyFactory(
class SingleTypeFactory (line 153) | private static final class SingleTypeFactory implements TypeAdapterFac...
method SingleTypeFactory (line 160) | SingleTypeFactory(
method create (line 177) | @SuppressWarnings("unchecked") // guarded by typeToken.equals() call
class GsonContextImpl (line 191) | private final class GsonContextImpl
method serialize (line 193) | @Override
method serialize (line 198) | @Override
method deserialize (line 203) | @Override
FILE: gson/src/main/java/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java
class TypeAdapterRuntimeTypeWrapper (line 27) | final class TypeAdapterRuntimeTypeWrapper<T> extends TypeAdapter<T> {
method TypeAdapterRuntimeTypeWrapper (line 32) | TypeAdapterRuntimeTypeWrapper(Gson context, TypeAdapter<T> delegate, T...
method read (line 38) | @Override
method write (line 43) | @Override
method isReflective (line 81) | private static boolean isReflective(TypeAdapter<?> typeAdapter) {
method getRuntimeTypeIfMoreSpecific (line 97) | private static Type getRuntimeTypeIfMoreSpecific(Type type, Object val...
FILE: gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java
class TypeAdapters (line 60) | public final class TypeAdapters {
method TypeAdapters (line 61) | private TypeAdapters() {
method write (line 68) | @Override
method read (line 78) | @Override
method read (line 91) | @Override
method write (line 132) | @Override
method read (line 147) | @Override
method write (line 160) | @Override
method read (line 171) | @Override
method write (line 180) | @Override
method read (line 191) | @Override
method write (line 212) | @Override
method read (line 226) | @Override
method write (line 247) | @Override
method read (line 262) | @Override
method write (line 275) | @Override
method read (line 289) | @Override
method write (line 298) | @Override
method atomicLongAdapter (line 306) | public static TypeAdapter<AtomicLong> atomicLongAdapter(TypeAdapter<Nu...
method read (line 324) | @Override
method write (line 329) | @Override
method read (line 339) | @Override
method write (line 360) | @Override
method atomicLongArrayAdapter (line 372) | public static TypeAdapter<AtomicLongArray> atomicLongArrayAdapter(
method read (line 406) | @Override
method write (line 419) | @Override
method read (line 431) | @Override
method write (line 440) | @Override
class FloatAdapter (line 450) | private static class FloatAdapter extends TypeAdapter<Number> {
method FloatAdapter (line 453) | FloatAdapter(boolean strict) {
method read (line 457) | @Override
method write (line 466) | @Override
class DoubleAdapter (line 483) | private static class DoubleAdapter extends TypeAdapter<Number> {
method DoubleAdapter (line 486) | DoubleAdapter(boolean strict) {
method read (line 490) | @Override
method write (line 499) | @Override
method checkValidFloatingPoint (line 513) | private static void checkValidFloatingPoint(double value) {
method read (line 530) | @Override
method write (line 544) | @Override
method read (line 555) | @Override
method write (line 569) | @Override
method read (line 577) | @Override
method write (line 592) | @Override
method read (line 603) | @Override
method write (line 618) | @Override
method read (line 632) | @Override
method write (line 641) | @Override
method read (line 654) | @Override
method write (line 663) | @Override
method read (line 674) | @Override
method write (line 683) | @Override
method read (line 694) | @Override
method write (line 704) | @Override
method read (line 714) | @Override
method write (line 728) | @Override
method read (line 738) | @Override
method write (line 752) | @Override
method read (line 763) | @Override
method write (line 778) | @Override
method read (line 788) | @Override
method write (line 799) | @Override
class IntegerFieldsTypeAdapter (line 811) | abstract static class IntegerFieldsTypeAdapter<T> extends TypeAdapter<...
method IntegerFieldsTypeAdapter (line 814) | IntegerFieldsTypeAdapter(String... fields) {
method create (line 818) | abstract T create(long[] values);
method integerValues (line 820) | abstract long[] integerValues(T t);
method read (line 822) | @Override
method write (line 843) | @Override
method create (line 863) | @Override
method integerValues (line 874) | @Override
method toIntExact (line 888) | private static int toIntExact(long x) {
method read (line 901) | @Override
method write (line 930) | @Override
type FactorySupplier (line 945) | interface FactorySupplier {
method get (line 946) | TypeAdapterFactory get();
method javaTimeTypeAdapterFactory (line 949) | public static TypeAdapterFactory javaTimeTypeAdapterFactory() {
method newFactory (line 961) | @SuppressWarnings("TypeParameterNaming")
method newFactory (line 973) | @SuppressWarnings("TypeParameterNaming")
method newFactory (line 989) | @SuppressWarnings("TypeParameterNaming")
method newFactoryForMultipleTypes (line 1013) | @SuppressWarnings("TypeParameterNaming")
method newTypeHierarchyFactory (line 1041) | public static <T1> TypeAdapterFactory newTypeHierarchyFactory(
FILE: gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java
class ISO8601Utils (line 38) | @SuppressWarnings("MemberName") // legacy class name
method ISO8601Utils (line 40) | private ISO8601Utils() {}
method format (line 68) | public static String format(Date date) {
method format (line 79) | public static String format(Date date, boolean millis) {
method format (line 91) | public static String format(Date date, boolean millis, TimeZone tz) {
method parse (line 147) | public static Date parse(String date, ParsePosition pos) throws ParseE...
method checkOffset (line 319) | private static boolean checkOffset(String value, int offset, char expe...
method parseInt (line 332) | private static int parseInt(String value, int beginIndex, int endIndex)
method padInt (line 366) | private static void padInt(StringBuilder buffer, int value, int length) {
method indexOfNonDigit (line 377) | private static int indexOfNonDigit(String string, int offset) {
FILE: gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java
class ReflectionHelper (line 28) | public class ReflectionHelper {
method ReflectionHelper (line 44) | private ReflectionHelper() {}
method getInaccessibleTroubleshootingSuffix (line 46) | private static String getInaccessibleTroubleshootingSuffix(Exception e) {
method makeAccessible (line 66) | public static void makeAccessible(AccessibleObject object) throws Json...
method getAccessibleObjectDescription (line 89) | public static String getAccessibleObjectDescription(
method fieldToString (line 116) | public static String fieldToString(Field field) {
method constructorToString (line 124) | public static String constructorToString(Constructor<?> constructor) {
method appendExecutableParameters (line 133) | private static void appendExecutableParameters(
method isStatic (line 151) | public static boolean isStatic(Class<?> clazz) {
method isAnonymousOrNonStaticLocal (line 156) | public static boolean isAnonymousOrNonStaticLocal(Class<?> clazz) {
method tryMakeAccessible (line 166) | public static String tryMakeAccessible(Constructor<?> constructor) {
method isRecord (line 182) | public static boolean isRecord(Class<?> raw) {
method getRecordComponentNames (line 186) | public static String[] getRecordComponentNames(Class<?> raw) {
method getAccessor (line 191) | public static Method getAccessor(Class<?> raw, Field field) {
method getCanonicalRecordConstructor (line 195) | public static <T> Constructor<T> getCanonicalRecordConstructor(Class<T...
method createExceptionForUnexpectedIllegalAccess (line 199) | public static RuntimeException createExceptionForUnexpectedIllegalAccess(
method createExceptionForRecordReflectionException (line 209) | private static RuntimeException createExceptionForRecordReflectionExce...
class RecordHelper (line 223) | private abstract static class RecordHelper {
method isRecord (line 224) | abstract boolean isRecord(Class<?> clazz);
method getRecordComponentNames (line 226) | abstract String[] getRecordComponentNames(Class<?> clazz);
method getCanonicalRecordConstructor (line 228) | abstract <T> Constructor<T> getCanonicalRecordConstructor(Class<T> r...
method getAccessor (line 230) | abstract Method getAccessor(Class<?> raw, Field field);
class RecordSupportedHelper (line 233) | private static class RecordSupportedHelper extends RecordHelper {
method RecordSupportedHelper (line 239) | private RecordSupportedHelper() throws NoSuchMethodException, ClassN...
method isRecord (line 247) | @Override
method getRecordComponentNames (line 256) | @Override
method getCanonicalRecordConstructor (line 270) | @Override
method getAccessor (line 286) | @Override
class RecordNotSupportedHelper (line 300) | private static class RecordNotSupportedHelper extends RecordHelper {
method isRecord (line 302) | @Override
method getRecordComponentNames (line 307) | @Override
method getCanonicalRecordConstructor (line 313) | @Override
method getAccessor (line 319) | @Override
FILE: gson/src/main/java/com/google/gson/internal/sql/SqlDateTypeAdapter.java
class SqlDateTypeAdapter (line 39) | @SuppressWarnings("JavaUtilDate")
method create (line 43) | @SuppressWarnings("unchecked") // we use a runtime check to make sure ...
method SqlDateTypeAdapter (line 54) | private SqlDateTypeAdapter() {}
method read (line 56) | @Override
method write (line 77) | @Override
FILE: gson/src/main/java/com/google/gson/internal/sql/SqlTimeTypeAdapter.java
class SqlTimeTypeAdapter (line 40) | @SuppressWarnings("JavaUtilDate")
method create (line 44) | @SuppressWarnings("unchecked") // we use a runtime check to make sure ...
method SqlTimeTypeAdapter (line 55) | private SqlTimeTypeAdapter() {}
method read (line 57) | @Override
method write (line 78) | @Override
FILE: gson/src/main/java/com/google/gson/internal/sql/SqlTimestampTypeAdapter.java
class SqlTimestampTypeAdapter (line 29) | @SuppressWarnings("JavaUtilDate")
method create (line 33) | @SuppressWarnings("unchecked") // we use a runtime check to make sure ...
method SqlTimestampTypeAdapter (line 47) | private SqlTimestampTypeAdapter(TypeAdapter<Date> dateTypeAdapter) {
method read (line 51) | @Override
method write (line 57) | @Override
FILE: gson/src/main/java/com/google/gson/internal/sql/SqlTypesSupport.java
class SqlTypesSupport (line 38) | @SuppressWarnings("JavaUtilDate")
method deserialize (line 65) | @Override
method deserialize (line 72) | @Override
method SqlTypesSupport (line 97) | private SqlTypesSupport() {}
FILE: gson/src/main/java/com/google/gson/reflect/TypeToken.java
class TypeToken (line 54) | public class TypeToken<T> {
method TypeToken (line 72) | @SuppressWarnings("unchecked")
method TypeToken (line 80) | @SuppressWarnings("unchecked")
method isCapturingTypeVariablesForbidden (line 87) | private static boolean isCapturingTypeVariablesForbidden() {
method getTypeTokenTypeArgument (line 95) | private Type getTypeTokenTypeArgument() {
method verifyNoTypeVariable (line 121) | private static void verifyNoTypeVariable(Type type) {
method getRawType (line 161) | public final Class<? super T> getRawType() {
method getType (line 166) | public final Type getType() {
method isAssignableFrom (line 175) | @Deprecated
method isAssignableFrom (line 185) | @Deprecated
method isAssignableFrom (line 213) | @Deprecated
method isAssignableFrom (line 222) | private static boolean isAssignableFrom(Type from, GenericArrayType to) {
method isAssignableFrom (line 244) | private static boolean isAssignableFrom(
method typeEquals (line 297) | private static boolean typeEquals(
method buildUnsupportedTypeException (line 312) | private static IllegalArgumentException buildUnsupportedTypeException(
method matches (line 333) | private static boolean matches(Type from, Type to, Map<String, Type> t...
method hashCode (line 339) | @Override
method equals (line 344) | @Override
method toString (line 349) | @Override
method get (line 355) | public static TypeToken<?> get(Type type) {
method get (line 360) | public static <T> TypeToken<T> get(Class<T> type) {
method getParameterized (line 385) | public static TypeToken<?> getParameterized(Type rawType, Type... type...
method getArray (line 449) | public static TypeToken<?> getArray(Type componentType) {
FILE: gson/src/main/java/com/google/gson/stream/JsonReader.java
class JsonReader (line 211) | public class JsonReader implements Closeable {
method JsonReader (line 314) | public JsonReader(Reader in) {
method setLenient (line 331) | @Deprecated
method isLenient (line 344) | public final boolean isLenient() {
method setStrictness (line 402) | public final void setStrictness(Strictness strictness) {
method getStrictness (line 413) | public final Strictness getStrictness() {
method setNestingLimit (line 435) | public final void setNestingLimit(int limit) {
method getNestingLimit (line 448) | public final int getNestingLimit() {
method beginArray (line 458) | public void beginArray() throws IOException {
method endArray (line 478) | public void endArray() throws IOException {
method beginObject (line 498) | public void beginObject() throws IOException {
method endObject (line 517) | public void endObject() throws IOException {
method hasNext (line 533) | public boolean hasNext() throws IOException {
method peek (line 542) | public JsonToken peek() throws IOException {
method doPeek (line 581) | @SuppressWarnings("fallthrough")
method peekKeyword (line 732) | private int peekKeyword() throws IOException {
method peekNumber (line 782) | private int peekNumber() throws IOException {
method isLiteral (line 894) | @SuppressWarnings("fallthrough")
method nextName (line 925) | public String nextName() throws IOException {
method nextString (line 951) | public String nextString() throws IOException {
method nextBoolean (line 984) | public boolean nextBoolean() throws IOException {
method nextNull (line 1006) | public void nextNull() throws IOException {
method nextDouble (line 1029) | public double nextDouble() throws IOException {
method nextLong (line 1072) | public long nextLong() throws IOException {
method nextQuotedValue (line 1125) | private String nextQuotedValue(char quote) throws IOException {
method nextUnquotedValue (line 1182) | @SuppressWarnings("fallthrough")
method skipQuotedValue (line 1241) | private void skipQuotedValue(char quote) throws IOException {
method skipUnquotedValue (line 1268) | @SuppressWarnings("fallthrough")
method nextInt (line 1310) | public int nextInt() throws IOException {
method close (line 1367) | @Override
method skipValue (line 1391) | public void skipValue() throws IOException {
method push (line 1468) | private void push(int newTop) throws MalformedJsonException {
method fillBuffer (line 1488) | private boolean fillBuffer(int minimum) throws IOException {
method nextNonWhitespace (line 1522) | private int nextNonWhitespace(boolean throwOnEof) throws IOException {
method checkLenient (line 1611) | private void checkLenient() throws MalformedJsonException {
method skipToEndOfLine (line 1622) | private void skipToEndOfLine() throws IOException {
method skipTo (line 1638) | private boolean skipTo(String toFind) throws IOException {
method toString (line 1657) | @Override
method locationString (line 1662) | String locationString() {
method getPath (line 1668) | private String getPath(boolean usePreviousPath) {
method getPath (line 1715) | public String getPath() {
method getPreviousPath (line 1733) | public String getPreviousPath() {
method readEscapeCharacter (line 1744) | @SuppressWarnings("fallthrough")
method syntaxError (line 1815) | private MalformedJsonException syntaxError(String message) throws Malf...
method unexpectedTokenError (line 1820) | private IllegalStateException unexpectedTokenError(String expected) th...
method consumeNonExecutePrefix (line 1835) | private void consumeNonExecutePrefix() throws IOException {
method validateAscii (line 1858) | private void validateAscii(String s) throws MalformedJsonException {
method promoteNameToValue (line 1869) | @Override
FILE: gson/src/main/java/com/google/gson/stream/JsonScope.java
class JsonScope (line 25) | final class JsonScope {
method JsonScope (line 26) | private JsonScope() {}
FILE: gson/src/main/java/com/google/gson/stream/JsonToken.java
type JsonToken (line 25) | public enum JsonToken {
FILE: gson/src/main/java/com/google/gson/stream/JsonWriter.java
class JsonWriter (line 162) | public class JsonWriter implements Closeable, Flushable {
method JsonWriter (line 231) | public JsonWriter(Writer out) {
method setIndent (line 248) | public final void setIndent(String indent) {
method setFormattingStyle (line 266) | public final void setFormattingStyle(FormattingStyle formattingStyle) {
method getFormattingStyle (line 292) | public final FormattingStyle getFormattingStyle() {
method setLenient (line 309) | @Deprecated
method isLenient (line 322) | public boolean isLenient() {
method setStrictness (line 345) | public final void setStrictness(Strictness strictness) {
method getStrictness (line 355) | public final Strictness getStrictness() {
method setHtmlSafe (line 367) | public final void setHtmlSafe(boolean htmlSafe) {
method isHtmlSafe (line 376) | public final boolean isHtmlSafe() {
method setSerializeNulls (line 386) | public final void setSerializeNulls(boolean serializeNulls) {
method getSerializeNulls (line 396) | public final boolean getSerializeNulls() {
method beginArray (line 406) | @CanIgnoreReturnValue
method endArray (line 417) | @CanIgnoreReturnValue
method beginObject (line 428) | @CanIgnoreReturnValue
method endObject (line 439) | @CanIgnoreReturnValue
method openScope (line 445) | @CanIgnoreReturnValue
method closeScope (line 454) | @CanIgnoreReturnValue
method push (line 472) | private void push(int newTop) {
method peek (line 480) | private int peek() {
method replaceTop (line 488) | private void replaceTop(int topOfStack) {
method name (line 498) | @CanIgnoreReturnValue
method writeDeferredName (line 512) | private void writeDeferredName() throws IOException {
method value (line 526) | @CanIgnoreReturnValue
method value (line 542) | @CanIgnoreReturnValue
method value (line 556) | @CanIgnoreReturnValue
method value (line 577) | @CanIgnoreReturnValue
method value (line 597) | @CanIgnoreReturnValue
method value (line 613) | @CanIgnoreReturnValue
method value (line 632) | @CanIgnoreReturnValue
method nullValue (line 666) | @CanIgnoreReturnValue
method jsonValue (line 691) | @CanIgnoreReturnValue
method flush (line 705) | @Override
method close (line 718) | @Override
method alwaysCreatesValidJsonNumber (line 730) | private static boolean alwaysCreatesValidJsonNumber(Class<? extends Nu...
method string (line 743) | private void string(String value) throws IOException {
method newline (line 775) | private void newline() throws IOException {
method beforeName (line 790) | private void beforeName() throws IOException {
method beforeValue (line 805) | @SuppressWarnings("fallthrough")
FILE: gson/src/main/java/com/google/gson/stream/MalformedJsonException.java
class MalformedJsonException (line 26) | public final class MalformedJsonException extends IOException {
method MalformedJsonException (line 29) | public MalformedJsonException(String msg) {
method MalformedJsonException (line 33) | public MalformedJsonException(String msg, Throwable throwable) {
method MalformedJsonException (line 37) | public MalformedJsonException(Throwable throwable) {
FILE: gson/src/test/java/com/google/gson/CommentsTest.java
class CommentsTest (line 30) | public final class CommentsTest {
method testParseComments (line 33) | @Test
FILE: gson/src/test/java/com/google/gson/DefaultInetAddressTypeAdapterTest.java
class DefaultInetAddressTypeAdapterTest (line 30) | public class DefaultInetAddressTypeAdapterTest {
method setUp (line 33) | @Before
method testInetAddressSerializationAndDeserialization (line 38) | @Test
FILE: gson/src/test/java/com/google/gson/DefaultMapJsonSerializerTest.java
class DefaultMapJsonSerializerTest (line 33) | public class DefaultMapJsonSerializerTest {
method testEmptyMapNoTypeSerialization (line 36) | @Test
method testEmptyMapSerialization (line 45) | @Test
method testNonEmptyMapSerialization (line 56) | @Test
FILE: gson/src/test/java/com/google/gson/ExposeAnnotationExclusionStrategyTest.java
class ExposeAnnotationExclusionStrategyTest (line 31) | public class ExposeAnnotationExclusionStrategyTest {
method assertIncludesClass (line 34) | private void assertIncludesClass(Class<?> c) {
method assertIncludesField (line 39) | private void assertIncludesField(Field f) {
method assertExcludesField (line 44) | private void assertExcludesField(Field f) {
method testNeverSkipClasses (line 49) | @Test
method testSkipNonAnnotatedFields (line 54) | @Test
method testSkipExplicitlySkippedFields (line 60) | @Test
method testNeverSkipExposedAnnotatedFields (line 66) | @Test
method testNeverSkipExplicitlyExposedAnnotatedFields (line 72) | @Test
method testDifferentSerializeAndDeserializeField (line 78) | @Test
method createFieldAttributes (line 85) | private static Field createFieldAttributes(String fieldName) throws Ex...
class MockObject (line 89) | @SuppressWarnings("unused")
FILE: gson/src/test/java/com/google/gson/FieldAttributesTest.java
class FieldAttributesTest (line 35) | public class FieldAttributesTest {
method setUp (line 38) | @Before
method testNullField (line 43) | @Test
method testDeclaringClass (line 48) | @Test
method testModifiers (line 53) | @Test
method testName (line 65) | @Test
method testDeclaredTypeAndClass (line 70) | @Test
class Foo (line 77) | private static class Foo {
FILE: gson/src/test/java/com/google/gson/FieldNamingPolicyTest.java
class FieldNamingPolicyTest (line 30) | public class FieldNamingPolicyTest {
method testSeparateCamelCase (line 31) | @Test
method testUpperCaseFirstLetter (line 51) | @Test
method testUpperCasingLocaleIndependent (line 75) | @Test
method testLowerCasingLocaleIndependent (line 114) | @Test
FILE: gson/src/test/java/com/google/gson/GenericArrayTypeTest.java
class GenericArrayTypeTest (line 35) | public class GenericArrayTypeTest {
method setUp (line 38) | @Before
method testOurTypeFunctionality (line 44) | @Test
method testNotEquals (line 54) | @Test
FILE: gson/src/test/java/com/google/gson/GsonBuilderTest.java
class GsonBuilderTest (line 39) | public class GsonBuilderTest {
method write (line 42) | @Override
method read (line 47) | @Override
method testCreatingMoreThanOnce (line 53) | @Test
method testModificationAfterCreate (line 72) | @Test
method assertDefaultGson (line 110) | private static void assertDefaultGson(Gson gson) {
method assertCustomGson (line 124) | private static void assertCustomGson(Gson gson) {
class CustomClass1 (line 135) | static class CustomClass1 {}
class CustomClass2 (line 137) | static class CustomClass2 {}
class CustomClass3 (line 139) | static class CustomClass3 {
method CustomClass3 (line 144) | public CustomClass3(String s) {
method CustomClass3 (line 148) | public CustomClass3() {
method testExcludeFieldsWithModifiers (line 153) | @Test
class HasModifiers (line 160) | @SuppressWarnings("unused")
method testTransientFieldExclusion (line 168) | @Test
class HasTransients (line 174) | static class HasTransients {
method testRegisterTypeAdapterForCoreType (line 178) | @Test
method testDisableJdkUnsafe (line 188) | @Test
class ClassWithoutNoArgsConstructor (line 204) | private static class ClassWithoutNoArgsConstructor {
method ClassWithoutNoArgsConstructor (line 205) | @SuppressWarnings({"unused", "EffectivelyPrivate"})
method testSetVersionInvalid (line 209) | @Test
method testDefaultStrictness (line 219) | @Test
method testSetLenient (line 229) | @SuppressWarnings({"deprecation", "InlineMeInliner"}) // for GsonBuild...
method testSetStrictness (line 241) | @Test
method testRegisterTypeAdapterNotAdapterClass (line 251) | @Test
method testRegisterTypeAdapterForObjectAndJsonElements (line 265) | @Test
method testRegisterTypeAdapterForJsonElements (line 288) | @Test
method testRegisterTypeHierarchyAdapterNotAdapterClass (line 297) | @Test
method testRegisterTypeHierarchyAdapterJsonElements (line 311) | @Ignore(
method testRegisterTypeHierarchyAdapterJsonElements_Allowed (line 337) | @Test
method testSetDateFormatWithInvalidPattern (line 347) | @Test
method testSetDateFormatWithValidPattern (line 358) | @Test
method testSetDateFormatNullPattern (line 366) | @Test
method testSetDateFormatEmptyPattern (line 385) | @Test
method testSetDateFormatValidStyle (line 397) | @SuppressWarnings("deprecation") // for GsonBuilder.setDateFormat(int)
method testSetDateFormatInvalidStyle (line 410) | @SuppressWarnings("deprecation") // for GsonBuilder.setDateFormat(int)
FILE: gson/src/test/java/com/google/gson/GsonTest.java
class GsonTest (line 41) | public final class GsonTest {
method createGson (line 52) | private static Gson createGson() {
method testStrictnessDefault (line 63) | @Test
method testOverridesDefaultExcluder (line 68) | @Test
method testClonedTypeAdapterFactoryListsAreIndependent (line 78) | @Test
class TestTypeAdapter (line 88) | private static final class TestTypeAdapter extends TypeAdapter<Object> {
method write (line 89) | @Override
method read (line 94) | @Override
method testFromJson_WrongResultType (line 100) | @Test
method testGetAdapter_Null (line 155) | @Test
method testGetAdapter_Concurrency (line 163) | @Test
method testGetAdapter_FutureAdapterConcurrency (line 231) | @Test
method testGetDelegateAdapter (line 333) | @Test
method testNewJsonWriter_Default (line 419) | @Test
method testNewJsonWriter_Custom (line 438) | @SuppressWarnings({"deprecation", "InlineMeInliner"}) // for GsonBuild...
method testNewJsonReader_Default (line 465) | @Test
method testNewJsonReader_Custom (line 473) | @SuppressWarnings({"deprecation", "InlineMeInliner"}) // for GsonBuild...
method testDefaultGsonNewBuilderModification (line 487) | @Test
method assertDefaultGson (line 524) | private static void assertDefaultGson(Gson gson) {
method testNewBuilderModification (line 542) | @Test
method assertCustomGson (line 610) | private static void assertCustomGson(Gson gson) {
class CustomClass1 (line 621) | private static class CustomClass1 {}
class CustomClass2 (line 623) | private static class CustomClass2 {}
class CustomClass3 (line 625) | private static class CustomClass3 {
method CustomClass3 (line 630) | @SuppressWarnings("EffectivelyPrivate")
method CustomClass3 (line 635) | @SuppressWarnings({"unused", "EffectivelyPrivate"}) // called by Gson
FILE: gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java
class GsonTypeAdapterTest (line 35) | public class GsonTypeAdapterTest {
method setUp (line 38) | @Before
method testDefaultTypeAdapterThrowsParseException (line 47) | @Test
method testTypeAdapterThrowsException (line 52) | @Test
method testTypeAdapterProperlyConvertsTypes (line 67) | @Test
method testTypeAdapterDoesNotAffectNonAdaptedTypes (line 78) | @Test
class ExceptionTypeAdapter (line 88) | private static class ExceptionTypeAdapter
method serialize (line 94) | @Override
method deserialize (line 99) | @Override
class AtomicIntegerTypeAdapter (line 107) | private static class AtomicIntegerTypeAdapter
method serialize (line 109) | @Override
method deserialize (line 115) | @Override
class Abstract (line 124) | abstract static class Abstract {
class Concrete (line 128) | static class Concrete extends Abstract {
method testDeserializerForAbstractClass (line 133) | @Test
method assertSerialized (line 148) | private static void assertSerialized(
FILE: gson/src/test/java/com/google/gson/InnerClassExclusionStrategyTest.java
class InnerClassExclusionStrategyTest (line 30) | public class InnerClassExclusionStrategyTest {
method assertIncludesClass (line 35) | private void assertIncludesClass(Class<?> c) {
method assertExcludesClass (line 40) | private void assertExcludesClass(Class<?> c) {
method assertIncludesField (line 45) | private void assertIncludesField(Field f) {
method assertExcludesField (line 50) | private void assertExcludesField(Field f) {
method testExcludeInnerClassObject (line 55) | @Test
method testExcludeInnerClassField (line 61) | @Test
method testIncludeStaticNestedClassObject (line 67) | @Test
method testIncludeStaticNestedClassField (line 73) | @Test
class InnerClass (line 79) | @SuppressWarnings("ClassCanBeStatic")
class StaticNestedClass (line 82) | static class StaticNestedClass {}
FILE: gson/src/test/java/com/google/gson/JavaSerializationTest.java
class JavaSerializationTest (line 37) | public final class JavaSerializationTest {
method testMapIsSerializable (line 40) | @Test
method testListIsSerializable (line 50) | @Test
method testNumberIsSerializable (line 58) | @Test
method serializedCopy (line 68) | @SuppressWarnings("unchecked") // Serialization promises to return the...
FILE: gson/src/test/java/com/google/gson/JsonArrayAsListSuiteTest.java
class JsonArrayAsListSuiteTest (line 19) | @RunWith(AllTests.class)
class ListGenerator (line 21) | private static class ListGenerator implements TestListGenerator<JsonEl...
method samples (line 22) | @Override
method createArray (line 32) | @Override
method order (line 37) | @Override
method create (line 42) | @Override
method suite (line 57) | public static Test suite() {
FILE: gson/src/test/java/com/google/gson/JsonArrayAsListTest.java
class JsonArrayAsListTest (line 33) | public class JsonArrayAsListTest {
method testGet (line 34) | @Test
method testSize (line 49) | @Test
method testSet (line 60) | @Test
method testAdd (line 78) | @Test
method testAddAll (line 109) | @Test
method testRemoveIndex (line 132) | @Test
method testRemoveElement (line 145) | @Test
method testClear (line 159) | @Test
method testContains (line 170) | @Test
method testIndexOf (line 187) | @Test
method spliteratorToList (line 208) | private <T> List<T> spliteratorToList(Spliterator<T> spliterator) {
method testSpliterator (line 212) | @Test
method testSort (line 229) | @Test
method testReplaceAll (line 249) | @Test
method testToArray (line 269) | @Test
method testEqualsHashCode (line 290) | @Test
method testViewUpdates (line 302) | @Test
FILE: gson/src/test/java/com/google/gson/JsonArrayTest.java
class JsonArrayTest (line 32) | public final class JsonArrayTest {
method testEqualsOnEmptyArray (line 34) | @Test
method testEqualsNonEmptyArray (line 39) | @Test
method testRemove (line 62) | @Test
method testSet (line 78) | @Test
method testDeepCopy (line 101) | @Test
method testIsEmpty (line 117) | @Test
method testFailedGetArrayValues (line 130) | @Test
method testGetAs_WrongArraySize (line 169) | @Test
method testStringPrimitiveAddition (line 181) | @Test
method testIntegerPrimitiveAddition (line 195) | @Test
method testDoublePrimitiveAddition (line 219) | @Test
method testBooleanPrimitiveAddition (line 242) | @Test
method testCharPrimitiveAddition (line 256) | @Test
method testMixedPrimitiveAddition (line 272) | @Test
method testNullPrimitiveAddition (line 294) | @Test
method testNullJsonElementAddition (line 315) | @Test
method testSameAddition (line 322) | @Test
method testToString (line 341) | @Test
FILE: gson/src/test/java/com/google/gson/JsonNullTest.java
class JsonNullTest (line 29) | public final class JsonNullTest {
method testEqualsAndHashcode (line 31) | @SuppressWarnings("deprecation")
method testDeepCopy (line 39) | @Test
method testToString (line 47) | @Test
FILE: gson/src/test/java/com/google/gson/JsonObjectAsMapSuiteTest.java
class JsonObjectAsMapSuiteTest (line 21) | @RunWith(AllTests.class)
class MapGenerator (line 23) | private static class MapGenerator implements TestMapGenerator<String, ...
method samples (line 24) | @Override
method create (line 34) | @Override
method createArray (line 48) | @SuppressWarnings("unchecked")
method order (line 54) | @Override
method createKeyArray (line 61) | @Override
method createValueArray (line 66) | @Override
method suite (line 73) | public static Test suite() {
FILE: gson/src/test/java/com/google/gson/JsonObjectAsMapTest.java
class JsonObjectAsMapTest (line 36) | public class JsonObjectAsMapTest {
method testSize (line 37) | @Test
method testContainsKey (line 51) | @Test
method testContainsValue (line 62) | @Test
method testGet (line 78) | @Test
method testPut (line 89) | @Test
method testRemove (line 113) | @Test
method testPutAll (line 133) | @Test
method testClear (line 160) | @Test
method testKeySet (line 171) | @Test
method testValues (line 190) | @Test
method testEntrySet (line 211) | @Test
method testEqualsHashCode (line 253) | @Test
method testViewUpdates (line 265) | @Test
FILE: gson/src/test/java/com/google/gson/JsonObjectTest.java
class JsonObjectTest (line 41) | public class JsonObjectTest {
method testAddingAndRemovingObjectProperties (line 43) | @Test
method testAddingNullPropertyValue (line 62) | @Test
method testAddingNullOrEmptyPropertyName (line 75) | @Test
method testAddingBooleanProperties (line 86) | @Test
method testAddingStringProperties (line 99) | @Test
method testAddingCharacterProperties (line 114) | @Test
method testPropertyWithQuotes (line 134) | @Test
method testWritePropertyWithEmptyStringName (line 143) | @Test
method testReadPropertyWithEmptyStringName (line 150) | @Test
method testEqualsOnEmptyObject (line 156) | @Test
method testEqualsNonEmptyObject (line 161) | @Test
method testEqualsHashCodeIgnoringOrder (line 184) | @Test
method testSize (line 201) | @Test
method testIsEmpty (line 216) | @Test
method testDeepCopy (line 228) | @Test
method testKeySet (line 242) | @Test
method testEntrySet (line 275) | @Test
method testToString (line 342) | @Test
FILE: gson/src/test/java/com/google/gson/JsonParserParameterizedTest.java
class JsonParserParameterizedTest (line 29) | @RunWith(Parameterized.class)
method data (line 31) | @Parameters
method testParse (line 47) | @Test
FILE: gson/src/test/java/com/google/gson/JsonParserTest.java
class JsonParserTest (line 36) | public class JsonParserTest {
method testParseInvalidJson (line 38) | @Test
method testParseUnquotedStringArrayFails (line 43) | @Test
method testParseString (line 52) | @Test
method testParseEmptyString (line 61) | @Test
method testParseEmptyWhitespaceInput (line 68) | @Test
method testParseUnquotedSingleWordStringFails (line 74) | @Test
method testParseUnquotedMultiWordStringFails (line 79) | @Test
method testParseMixedArray (line 85) | @Test
method testParseDeeplyNestedArrays (line 98) | @Test
method testParseDeeplyNestedObjects (line 120) | @Test
method testParseReader (line 143) | @Test
method testReadWriteTwoObjects (line 152) | @Test
method testLegacyStrict (line 172) | @Test
method testStrict (line 184) | @Test
FILE: gson/src/test/java/com/google/gson/JsonPrimitiveTest.java
class JsonPrimitiveTest (line 33) | public class JsonPrimitiveTest {
method testNulls (line 35) | @SuppressWarnings("unused")
method testBoolean (line 44) | @Test
method testParsingStringAsBoolean (line 68) | @Test
method testParsingStringAsNumber (line 76) | @Test
method testAsNumber_Boolean (line 91) | @Test
method testStringsAndChar (line 98) | @SuppressWarnings("deprecation")
method testExponential (line 121) | @Test
method testByteEqualsShort (line 132) | @Test
method testByteEqualsInteger (line 140) | @Test
method testByteEqualsLong (line 148) | @Test
method testByteEqualsBigInteger (line 156) | @Test
method testShortEqualsInteger (line 164) | @Test
method testShortEqualsLong (line 172) | @Test
method testShortEqualsBigInteger (line 180) | @Test
method testIntegerEqualsLong (line 188) | @Test
method testIntegerEqualsBigInteger (line 196) | @Test
method testLongEqualsBigInteger (line 204) | @Test
method testFloatEqualsDouble (line 212) | @Test
method testFloatEqualsBigDecimal (line 220) | @Test
method testDoubleEqualsBigDecimal (line 228) | @Test
method testToString (line 236) | @Test
method testEquals (line 267) | @Test
method testEqualsAcrossTypes (line 289) | @Test
method testEqualsIntegerAndBigInteger (line 301) | @Test
method testEqualsDoesNotEquateStringAndNonStringTypes (line 308) | @Test
method testDeepCopy (line 315) | @Test
method testBigDecimalEquals (line 321) | @Test
method testBigDecimalEqualsZero (line 333) | @Test
method testBigDecimalEqualsTransitive (line 350) | @Test
method testEqualsDoubleNaNAndBigDecimal (line 362) | @Test
FILE: gson/src/test/java/com/google/gson/JsonStreamParserTest.java
class JsonStreamParserTest (line 31) | public class JsonStreamParserTest {
method setUp (line 34) | @Before
method testParseTwoStrings (line 39) | @Test
method testIterator (line 47) | @Test
method testNoSideEffectForHasNext (line 56) | @Test
method testCallingNextBeyondAvailableInput (line 71) | @Test
method testEmptyInput (line 79) | @Test
method testIncompleteInput (line 90) | @Test
method testMalformedInput (line 97) | @Test
FILE: gson/src/test/java/com/google/gson/LongSerializationPolicyTest.java
class LongSerializationPolicyTest (line 29) | public class LongSerializationPolicyTest {
method testDefaultLongSerialization (line 31) | @Test
method testDefaultLongSerializationIntegration (line 42) | @Test
method testDefaultLongSerializationNull (line 50) | @Test
method testStringLongSerialization (line 59) | @Test
method testStringLongSerializationIntegration (line 70) | @Test
method testStringLongSerializationNull (line 78) | @Test
FILE: gson/src/test/java/com/google/gson/MixedStreamTest.java
class MixedStreamTest (line 33) | public final class MixedStreamTest {
method testWriteMixedStreamed (line 54) | @Test
method testReadMixedStreamed (line 70) | @Test
method testReadDoesNotMutateState (line 83) | @SuppressWarnings("deprecation") // for JsonReader.setLenient
method testWriteDoesNotMutateState (line 101) | @SuppressWarnings("deprecation") // for JsonWriter.setLenient
method testReadInvalidState (line 121) | @Test
method testReadClosed (line 130) | @Test
method testWriteInvalidState (line 142) | @Test
method testWriteClosed (line 153) | @Test
method testWriteNulls (line 166) | @Test
method testReadNulls (line 178) | @Test
method testWriteHtmlSafeWithEscaping (line 187) | @Test
method testWriteHtmlSafeWithoutEscaping (line 198) | @Test
method testWriteLenient (line 208) | @Test
class Car (line 234) | static final class Car {
method Car (line 238) | Car(String name, int color) {
method Car (line 244) | Car() {}
method hashCode (line 246) | @Override
method equals (line 251) | @Override
FILE: gson/src/test/java/com/google/gson/ObjectTypeAdapterParameterizedTest.java
class ObjectTypeAdapterParameterizedTest (line 29) | @RunWith(Parameterized.class)
method data (line 31) | @Parameters
method testReadWrite (line 47) | @Test
FILE: gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java
class ObjectTypeAdapterTest (line 31) | public final class ObjectTypeAdapterTest {
method testDeserialize (line 35) | @Test
method testSerialize (line 44) | @Test
method testSerializeNullValue (line 50) | @Test
method testDeserializeNullValue (line 57) | @Test
method testSerializeObject (line 64) | @Test
method testDeserializeDeeplyNestedArrays (line 70) | @SuppressWarnings("unchecked")
method testDeserializeDeeplyNestedObjects (line 93) | @SuppressWarnings("unchecked")
class RuntimeType (line 112) | @SuppressWarnings({"unused", "ClassCanBeStatic"})
FILE: gson/src/test/java/com/google/gson/OverrideCoreTypeAdaptersTest.java
class OverrideCoreTypeAdaptersTest (line 32) | public class OverrideCoreTypeAdaptersTest {
method write (line 35) | @Override
method read (line 40) | @Override
method write (line 49) | @Override
method read (line 54) | @Override
method testOverrideWrapperBooleanAdapter (line 60) | @Test
method testOverridePrimitiveBooleanAdapter (line 70) | @Test
method testOverrideStringAdapter (line 80) | @Test
FILE: gson/src/test/java/com/google/gson/ParameterizedTypeFixtures.java
class ParameterizedTypeFixtures (line 34) | public class ParameterizedTypeFixtures {
method ParameterizedTypeFixtures (line 35) | private ParameterizedTypeFixtures() {}
class MyParameterizedType (line 37) | public static final class MyParameterizedType<T> {
method MyParameterizedType (line 40) | public MyParameterizedType(T value) {
method getValue (line 44) | public T getValue() {
method getExpectedJson (line 48) | public String getExpectedJson() {
method getExpectedJson (line 53) | private static String getExpectedJson(Object obj) {
method hashCode (line 71) | @Override
method equals (line 76) | @Override
class MyParameterizedTypeInstanceCreator (line 89) | public static class MyParameterizedTypeInstanceCreator<T>
method MyParameterizedTypeInstanceCreator (line 98) | public MyParameterizedTypeInstanceCreator(T instanceOfT) {
method createInstance (line 102) | @Override
class MyParameterizedTypeAdapter (line 108) | public static final class MyParameterizedTypeAdapter<T>
method getExpectedJson (line 110) | @SuppressWarnings("unchecked")
method serialize (line 127) | @Override
method deserialize (line 136) | @SuppressWarnings("unchecked")
FILE: gson/src/test/java/com/google/gson/ParameterizedTypeTest.java
class ParameterizedTypeTest (line 35) | public class ParameterizedTypeTest {
method setUp (line 38) | @Before
method testOurTypeFunctionality (line 43) | @Test
method testNotEquals (line 53) | @Test
FILE: gson/src/test/java/com/google/gson/PrimitiveTypeAdapter.java
class PrimitiveTypeAdapter (line 30) | final class PrimitiveTypeAdapter {
method adaptType (line 32) | @SuppressWarnings("unchecked")
FILE: gson/src/test/java/com/google/gson/SubsetTest.java
class SubsetTest (line 9) | public final class SubsetTest {
method read (line 10) | @Test
method write (line 20) | @Test
FILE: gson/src/test/java/com/google/gson/ToNumberPolicyTest.java
class ToNumberPolicyTest (line 30) | public class ToNumberPolicyTest {
method testDouble (line 31) | @Test
method testLazilyParsedNumber (line 50) | @Test
method testLongOrDouble (line 59) | @Test
method testBigDecimal (line 113) | @Test
method testNullsAreNeverExpected (line 127) | @Test
method fromString (line 170) | private static JsonReader fromString(String json) {
method fromStringLenient (line 174) | private static JsonReader fromStringLenient(String json) {
FILE: gson/src/test/java/com/google/gson/TypeAdapterTest.java
class TypeAdapterTest (line 28) | public class TypeAdapterTest {
method testNullSafe (line 29) | @Test
method testNullSafe_ReturningSameInstanceOnceNullSafe (line 37) | @Test
method testNullSafe_ToString (line 46) | @Test
method write (line 59) | @Override
method read (line 64) | @Override
method toString (line 69) | @Override
method testToJson_ThrowingIOException (line 79) | @Test
method write (line 104) | @Override
method read (line 109) | @Override
method testFromJson_Reader_TrailingData (line 117) | @Test
method testFromJson_String_TrailingData (line 124) | @Test
FILE: gson/src/test/java/com/google/gson/VersionExclusionStrategyTest.java
class VersionExclusionStrategyTest (line 33) | public class VersionExclusionStrategyTest {
method assertIncludesClass (line 36) | private static void assertIncludesClass(Excluder excluder, Class<?> c) {
method assertExcludesClass (line 41) | private static void assertExcludesClass(Excluder excluder, Class<?> c) {
method assertIncludesField (line 46) | private static void assertIncludesField(Excluder excluder, Field f) {
method assertExcludesField (line 51) | private static void assertExcludesField(Excluder excluder, Field f) {
method testSameVersion (line 56) | @Test
method testNewerVersion (line 70) | @Test
method testOlderVersion (line 83) | @Test
class MockClassSince (line 96) | @Since(VERSION)
class MockClassUntil (line 104) | @Until(VERSION)
class MockClassBoth (line 112) | @Since(VERSION)
FILE: gson/src/test/java/com/google/gson/common/MoreAsserts.java
class MoreAsserts (line 32) | public class MoreAsserts {
method MoreAsserts (line 33) | private MoreAsserts() {}
method assertContains (line 41) | public static <T> void assertContains(Collection<T> collection, T valu...
method assertEqualsAndHashCode (line 50) | public static void assertEqualsAndHashCode(Object a, Object b) {
method isProtectedOrPublic (line 58) | private static boolean isProtectedOrPublic(Method method) {
method getMethodSignature (line 63) | private static String getMethodSignature(Method method) {
method assertOverridesMethods (line 81) | public static void assertOverridesMethods(
FILE: gson/src/test/java/com/google/gson/common/TestTypes.java
class TestTypes (line 38) | public class TestTypes {
method TestTypes (line 39) | private TestTypes() {}
class Base (line 41) | public static class Base {
class Sub (line 49) | public static class Sub extends Base {
class ClassWithBaseField (line 55) | public static class ClassWithBaseField {
method ClassWithBaseField (line 59) | public ClassWithBaseField(Base base) {
class ClassWithBaseArrayField (line 64) | public static class ClassWithBaseArrayField {
method ClassWithBaseArrayField (line 68) | public ClassWithBaseArrayField(Base[] base) {
class ClassWithBaseCollectionField (line 73) | public static class ClassWithBaseCollectionField {
method ClassWithBaseCollectionField (line 77) | public ClassWithBaseCollectionField(Collection<Base> base) {
class BaseSerializer (line 82) | public static class BaseSerializer implements JsonSerializer<Base> {
method serialize (line 85) | @Override
class SubSerializer (line 93) | public static class SubSerializer implements JsonSerializer<Sub> {
method serialize (line 96) | @Override
class StringWrapper (line 104) | public static class StringWrapper {
method StringWrapper (line 107) | public StringWrapper(String value) {
class BagOfPrimitives (line 112) | public static class BagOfPrimitives {
method BagOfPrimitives (line 119) | public BagOfPrimitives() {
method BagOfPrimitives (line 123) | public BagOfPrimitives(long longValue, int intValue, boolean boolean...
method getIntValue (line 130) | public int getIntValue() {
method getExpectedJson (line 134) | public String getExpectedJson() {
method hashCode (line 145) | @Override
method equals (line 156) | @Override
method toString (line 171) | @Override
class BagOfPrimitiveWrappers (line 179) | public static class BagOfPrimitiveWrappers {
method BagOfPrimitiveWrappers (line 184) | public BagOfPrimitiveWrappers(Long longValue, Integer intValue, Bool...
method getExpectedJson (line 190) | public String getExpectedJson() {
class PrimitiveArray (line 201) | public static class PrimitiveArray {
method PrimitiveArray (line 204) | public PrimitiveArray() {
method PrimitiveArray (line 208) | public PrimitiveArray(long[] longArray) {
method getExpectedJson (line 212) | public String getExpectedJson() {
class ClassWithNoFields (line 232) | @SuppressWarnings({"overrides", "EqualsHashCode"})
method equals (line 235) | @Override
class Nested (line 241) | public static class Nested {
method Nested (line 245) | public Nested() {
method Nested (line 249) | public Nested(BagOfPrimitives primitive1, BagOfPrimitives primitive2) {
method getExpectedJson (line 254) | public String getExpectedJson() {
method appendFields (line 262) | public void appendFields(StringBuilder sb) {
class ClassWithTransientFields (line 275) | public static class ClassWithTransientFields<T> {
method ClassWithTransientFields (line 280) | public ClassWithTransientFields() {
method ClassWithTransientFields (line 284) | public ClassWithTransientFields(long value) {
method getExpectedJson (line 289) | public String getExpectedJson() {
class ClassWithCustomTypeConverter (line 298) | public static class ClassWithCustomTypeConverter {
method ClassWithCustomTypeConverter (line 302) | public ClassWithCustomTypeConverter() {
method ClassWithCustomTypeConverter (line 306) | public ClassWithCustomTypeConverter(int value) {
method ClassWithCustomTypeConverter (line 310) | public ClassWithCustomTypeConverter(BagOfPrimitives bag, int value) {
method getBag (line 315) | public BagOfPrimitives getBag() {
method getExpectedJson (line 319) | public String getExpectedJson() {
method getValue (line 323) | public int getValue() {
class ArrayOfObjects (line 328) | public static class ArrayOfObjects {
method ArrayOfObjects (line 331) | public ArrayOfObjects() {
method getExpectedJson (line 338) | public String getExpectedJson() {
class ClassOverridingEquals (line 354) | public static class ClassOverridingEquals {
method getExpectedJson (line 357) | public String getExpectedJson() {
method equals (line 364) | @Override
method hashCode (line 369) | @Override
class ClassWithArray (line 375) | public static class ClassWithArray {
method ClassWithArray (line 378) | public ClassWithArray() {
method ClassWithArray (line 382) | public ClassWithArray(Object[] array) {
class ClassWithObjects (line 387) | public static class ClassWithObjects {
method ClassWithObjects (line 390) | public ClassWithObjects() {
method ClassWithObjects (line 394) | public ClassWithObjects(BagOfPrimitives bag) {
class ClassWithSerializedNameFields (line 399) | public static class ClassWithSerializedNameFields {
method ClassWithSerializedNameFields (line 406) | public ClassWithSerializedNameFields() {
method ClassWithSerializedNameFields (line 410) | public ClassWithSerializedNameFields(int f, int g) {
method getExpectedJson (line 415) | public String getExpectedJson() {
class CrazyLongTypeAdapter (line 420) | public static class CrazyLongTypeAdapter implements JsonSerializer<Lon...
method serialize (line 423) | @Override
method deserialize (line 428) | @Override
FILE: gson/src/test/java/com/google/gson/functional/ArrayTest.java
class ArrayTest (line 41) | public class ArrayTest {
method setUp (line 44) | @Before
method testTopLevelArrayOfIntsSerialization (line 49) | @Test
method testTopLevelArrayOfIntsDeserialization (line 55) | @Test
method testInvalidArrayDeserialization (line 62) | @Test
method testEmptyArraySerialization (line 70) | @Test
method testEmptyArrayDeserialization (line 76) | @Test
method testNullsInArraySerialization (line 88) | @Test
method testNullsInArrayDeserialization (line 96) | @Test
method testSingleNullInArraySerialization (line 104) | @Test
method testSingleNullInArrayDeserialization (line 112) | @Test
method testNullsInArrayWithSerializeNullPropertySetSerialization (line 118) | @Test
method testArrayOfStringsSerialization (line 127) | @Test
method testArrayOfStringsDeserialization (line 133) | @Test
method testSingleStringArraySerialization (line 140) | @Test
method testSingleStringArrayDeserialization (line 147) | @Test
method testArrayOfCollectionSerialization (line 154) | @Test
method testArrayOfCollectionDeserialization (line 180) | @Test
method testArrayOfPrimitivesAsObjectsSerialization (line 191) | @Test
method testArrayOfPrimitivesAsObjectsDeserialization (line 200) | @Test
method testObjectArrayWithNonPrimitivesSerialization (line 211) | @Test
method testArrayOfNullSerialization (line 225) | @Test
method testArrayOfNullDeserialization (line 232) | @Test
method testMultidimensionalArraysSerialization (line 239) | @Test
method testMultidimensionalObjectArraysSerialization (line 250) | @Test
method testMultidimensionalPrimitiveArraysSerialization (line 256) | @Test
method testMixingTypesInObjectArraySerialization (line 263) | @Test
method testMultidimensionalArraysDeserialization (line 270) | @Test
method testMultidimensionalPrimitiveArraysDeserialization (line 280) | @Test
method testArrayElementsAreArrays (line 288) | @Test
FILE: gson/src/test/java/com/google/gson/functional/CircularReferenceTest.java
class CircularReferenceTest (line 42) | public class CircularReferenceTest {
method setUp (line 45) | @Before
method testCircularSerialization (line 50) | @Test
method testSelfReferenceIgnoredInSerialization (line 60) | @Test
method testSelfReferenceArrayFieldSerialization (line 69) | @Test
method testSelfReferenceCustomHandlerSerialization (line 78) | @Test
method assertThrowsStackOverflow (line 105) | private static void assertThrowsStackOverflow(ThrowingRunnable runnabl...
method testDirectedAcyclicGraphSerialization (line 112) | @Test
method testDirectedAcyclicGraphDeserialization (line 123) | @Test
class ContainsReferenceToSelfType (line 131) | private static class ContainsReferenceToSelfType {
class ClassWithSelfReference (line 135) | private static class ClassWithSelfReference {
class ClassWithSelfReferenceArray (line 139) | private static class ClassWithSelfReferenceArray {
FILE: gson/src/test/java/com/google/gson/functional/CollectionTest.java
class CollectionTest (line 57) | public class CollectionTest {
method setUp (line 60) | @Before
method testTopLevelCollectionOfIntegersSerialization (line 65) | @Test
method testTopLevelCollectionOfIntegersDeserialization (line 73) | @Test
method testTopLevelListOfIntegerCollectionsDeserialization (line 82) | @Test
method testLinkedListSerialization (line 100) | @Test
method testLinkedListDeserialization (line 112) | @Test
method testQueueSerialization (line 121) | @Test
method testQueueDeserialization (line 133) | @Test
method testPriorityQueue (line 143) | @Test
method testVector (line 155) | @Test
method testStack (line 167) | @Test
class CollectionWithoutNoArgsConstructor (line 179) | private static class CollectionWithoutNoArgsConstructor<E> extends Abs...
method CollectionWithoutNoArgsConstructor (line 181) | CollectionWithoutNoArgsConstructor(int unused) {}
method add (line 183) | @Override
method iterator (line 188) | @Override
method size (line 193) | @Override
method testCollectionWithoutNoArgsConstructor (line 204) | @Test
method testNullsInListSerialization (line 231) | @Test
method testNullsInListDeserialization (line 243) | @Test
method testCollectionOfObjectSerialization (line 257) | @Test
method testCollectionOfObjectWithNullSerialization (line 268) | @Test
method testCollectionOfStringsSerialization (line 280) | @Test
method testCollectionOfBagOfPrimitivesSerialization (line 288) | @Test
method testCollectionOfStringsDeserialization (line 304) | @Test
method testRawCollectionOfIntegersSerialization (line 313) | @Test
method testObjectCollectionSerialization (line 319) | @Test
method testRawCollectionDeserializationNotAllowed (line 327) | @Test
method testRawCollectionOfBagOfPrimitivesNotAllowed (line 341) | @Test
method testWildcardPrimitiveCollectionSerilaization (line 355) | @Test
method testWildcardPrimitiveCollectionDeserilaization (line 366) | @Test
method testWildcardCollectionField (line 376) | @Test
method testFieldIsArrayList (line 396) | @Test
method testUserCollectionTypeAdapter (line 407) | @Test
class HasArrayListField (line 422) | static class HasArrayListField {
method toIntArray (line 426) | private static int[] toIntArray(Collection<?> collection) {
class ObjectWithWildcardCollection (line 440) | private static class ObjectWithWildcardCollection {
method ObjectWithWildcardCollection (line 443) | ObjectWithWildcardCollection(Collection<? extends BagOfPrimitives> c...
method getCollection (line 447) | Collection<? extends BagOfPrimitives> getCollection() {
class Entry (line 452) | private static class Entry {
method Entry (line 455) | Entry(int value) {
method testSetSerialization (line 460) | @Test
method testSetDeserialization (line 470) | @Test
class BigClass (line 481) | private static class BigClass {
class SmallClass (line 485) | private static class SmallClass {
method testIssue1107 (line 489) | @Test
FILE: gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java
class ConcurrencyTest (line 34) | public class ConcurrencyTest {
method setUp (line 37) | @Before
method testSingleThreadSerialization (line 46) | @Test
method testSingleThreadDeserialization (line 58) | @Test
method testMultiThreadSerialization (line 72) | @Test
method testMultiThreadDeserialization (line 107) | @Test
class MyObject (line 137) | @SuppressWarnings("unused")
method MyObject (line 143) | MyObject() {
method MyObject (line 147) | MyObject(String a, String b, int i) {
FILE: gson/src/test/java/com/google/gson/functional/CustomDeserializerTest.java
class CustomDeserializerTest (line 40) | public class CustomDeserializerTest {
method setUp (line 46) | @Before
method testDefaultConstructorNotCalledOnObject (line 54) | @Test
method testDefaultConstructorNotCalledOnField (line 63) | @Test
class DataHolder (line 72) | private static class DataHolder {
method DataHolder (line 76) | @SuppressWarnings("unused")
method DataHolder (line 81) | DataHolder(String data) {
method getData (line 85) | String getData() {
class DataHolderWrapper (line 90) | private static class DataHolderWrapper {
method DataHolderWrapper (line 94) | @SuppressWarnings("unused")
method DataHolderWrapper (line 99) | DataHolderWrapper(DataHolder data) {
method getWrappedData (line 103) | DataHolder getWrappedData() {
class DataHolderDeserializer (line 108) | private static class DataHolderDeserializer implements JsonDeserialize...
method deserialize (line 109) | @Override
method testJsonTypeFieldBasedDeserialization (line 119) | @Test
class MyBase (line 137) | private static class MyBase {
type SubTypes (line 141) | @SuppressWarnings("ImmutableEnumChecker")
method SubTypes (line 147) | private SubTypes(Type subClass) {
method getSubclass (line 151) | Type getSubclass() {
class SubType1 (line 156) | private static class SubType1 extends MyBase {
class SubType2 (line 160) | private static class SubType2 extends MyBase {
method testCustomDeserializerReturnsNullForTopLevelObject (line 165) | @Test
method testCustomDeserializerReturnsNull (line 177) | @Test
method testCustomDeserializerReturnsNullForArrayElements (line 189) | @Test
method testCustomDeserializerReturnsNullForArrayElementsForArrayField (line 202) | @Test
class ClassWithBaseArray (line 215) | private static final class ClassWithBaseArray {
FILE: gson/src/test/java/com/google/gson/functional/CustomSerializerTest.java
class CustomSerializerTest (line 41) | public class CustomSerializerTest {
method testBaseClassSerializerInvokedForBaseClassFields (line 43) | @Test
method testSubClassSerializerInvokedForBaseClassFieldsHoldingSubClassInstances (line 56) | @Test
method testSubClassSerializerInvokedForBaseClassFieldsHoldingArrayOfSubClassInstances (line 69) | @Test
method testBaseClassSerializerInvokedForBaseClassFieldsHoldingSubClassInstances (line 85) | @Test
method testSerializerReturnsNull (line 94) | @Test
FILE: gson/src/test/java/com/google/gson/functional/CustomTypeAdaptersTest.java
class CustomTypeAdaptersTest (line 52) | public class CustomTypeAdaptersTest {
method setUp (line 55) | @Before
method testCustomSerializers (line 60) | @Test
method testCustomDeserializers (line 78) | @Test
method disable_testCustomSerializersOfSelf (line 97) | @Test
method disable_testCustomDeserializersOfSelf (line 109) | @Test
method testCustomNestedSerializers (line 122) | @Test
method testCustomNestedDeserializers (line 134) | @Test
method testCustomTypeAdapterDoesNotAppliesToSubClasses (line 151) | @Test
method testCustomTypeAdapterAppliesToSubClassesSerializedAsBaseClass (line 172) | @Test
class Base (line 194) | private static class Base {
class Derived (line 198) | private static class Derived extends Base {
method createGsonObjectWithFooTypeAdapter (line 203) | private Gson createGsonObjectWithFooTypeAdapter() {
class Foo (line 207) | public static class Foo {
method Foo (line 211) | public Foo() {
method Foo (line 215) | public Foo(int key, long value) {
class FooTypeAdapter (line 221) | public static final class FooTypeAdapter implements JsonSerializer<Foo...
method deserialize (line 222) | @Override
method serialize (line 228) | @Override
method testCustomSerializerInvokedForPrimitives (line 234) | @Test
method testCustomDeserializerInvokedForPrimitives (line 247) | @Test
method testCustomByteArraySerializer (line 259) | @Test
method testCustomByteArrayDeserializerAndInstanceCreator (line 279) | @Test
class StringHolder (line 303) | private static final class StringHolder {
method StringHolder (line 307) | StringHolder(String string) {
method StringHolder (line 313) | StringHolder(String part1, String part2) {
class StringHolderTypeAdapter (line 319) | private static class StringHolderTypeAdapter
method createInstance (line 324) | @Override
method deserialize (line 330) | @Override
method serialize (line 336) | @Override
method testCustomAdapterInvokedForCollectionElementSerializationWithType (line 345) | @Test
method testCustomAdapterInvokedForCollectionElementSerialization (line 360) | @Test
method testCustomAdapterInvokedForCollectionElementDeserialization (line 374) | @Test
method testCustomAdapterInvokedForMapElementSerializationWithType (line 389) | @Test
method testCustomAdapterInvokedForMapElementSerialization (line 404) | @Test
method testCustomAdapterInvokedForMapElementDeserialization (line 418) | @Test
method testEnsureCustomSerializerNotInvokedForNullValues (line 432) | @Test
method testEnsureCustomDeserializerNotInvokedForNullValues (line 443) | @Test
method testRegisterHierarchyAdapterForDate (line 455) | @Test
class DataHolder (line 466) | private static class DataHolder {
method DataHolder (line 469) | DataHolder(String data) {
class DataHolderWrapper (line 474) | private static class DataHolderWrapper {
method DataHolderWrapper (line 477) | DataHolderWrapper(DataHolder data) {
class DataHolderSerializer (line 482) | private static class DataHolderSerializer implements JsonSerializer<Da...
method serialize (line 483) | @Override
class DataHolderDeserializer (line 491) | private static class DataHolderDeserializer implements JsonDeserialize...
method deserialize (line 492) | @Override
class DateTypeAdapter (line 505) | @SuppressWarnings("JavaUtilDate")
method deserialize (line 507) | @Override
method serialize (line 514) | @Override
FILE: gson/src/test/java/com/google/gson/functional/DefaultTypeAdaptersTest.java
class DefaultTypeAdaptersTest (line 87) | @SuppressWarnings("JavaUtilDate")
method setUp (line 93) | @Before
method tearDown (line 102) | @After
method testClassSerialization (line 108) | @Test
method testClassDeserialization (line 124) | @Test
method testUrlSerialization (line 140) | @Test
method testUrlDeserialization (line 147) | @Test
method testUrlNullSerialization (line 158) | @Test
method testUrlNullDeserialization (line 164) | @Test
class ClassWithUrlField (line 171) | private static class ClassWithUrlField {
method testUriSerialization (line 175) | @Test
method testUriDeserialization (line 182) | @Test
method testNullSerialization (line 190) | @Test
method testNullSerializationAndDeserialization (line 229) | private void testNullSerializationAndDeserialization(Class<?> c) {
method testNullSerializationAndDeserialization (line 233) | public static void testNullSerializationAndDeserialization(Gson gson, ...
method testUuidSerialization (line 238) | @Test
method testUuidDeserialization (line 245) | @Test
method testLocaleSerializationWithLanguage (line 253) | @Test
method testLocaleDeserializationWithLanguage (line 259) | @Test
method testLocaleSerializationWithLanguageCountry (line 266) | @Test
method testLocaleDeserializationWithLanguageCountry (line 272) | @Test
method testLocaleSerializationWithLanguageCountryVariant (line 279) | @Test
method testLocaleDeserializationWithLanguageCountryVariant (line 286) | @Test
method testBigDecimalFieldSerialization (line 295) | @Test
method testBigDecimalFieldDeserialization (line 303) | @Test
method testBadValueForBigDecimalDeserialization (line 311) | @Test
method testBigIntegerFieldSerialization (line 319) | @Test
method testBigIntegerFieldDeserialization (line 326) | @Test
method testOverrideBigIntegerTypeAdapter (line 334) | @Test
method testOverrideBigDecimalTypeAdapter (line 344) | @Test
method testSetSerialization (line 354) | @Test
method testBitSetSerialization (line 366) | @Test
method testBitSetDeserialization (line 377) | @Test
method testDefaultDateSerialization (line 410) | @Test
method testDefaultDateDeserialization (line 417) | @Test
method assertEqualsDate (line 427) | @SuppressWarnings("deprecation")
method assertEqualsTime (line 434) | @SuppressWarnings("deprecation")
method testDefaultDateSerializationUsingBuilder (line 441) | @Test
method testDefaultDateDeserializationUsingBuilder (line 449) | @Test
method testDefaultCalendarSerialization (line 458) | @Test
method testDefaultCalendarDeserialization (line 470) | @Test
method testDefaultGregorianCalendarSerialization (line 483) | @Test
method testDefaultGregorianCalendarDeserialization (line 497) | @Test
method testDateSerializationWithStyle (line 529) | @Test
method testDateSerializationWithDateStyle (line 559) | @SuppressWarnings("deprecation") // for GsonBuilder.setDateFormat(int)
method testDateStyleOverwritesPattern (line 585) | @Test
method testDateSerializationWithPattern (line 601) | @SuppressWarnings("deprecation") // for GsonBuilder.setDateFormat(int)
method testDateDeserializationWithPattern (line 612) | @SuppressWarnings("deprecation")
method testDateSerializationWithPatternNotOverridenByTypeAdapter (line 626) | @Test
method testDateSerializationInCollection (line 643) | @Test
method testJsonPrimitiveSerialization (line 663) | @Test
method testJsonPrimitiveDeserialization (line 671) | @Test
method testJsonNullSerialization (line 683) | @Test
method testNullJsonElementSerialization (line 689) | @Test
method testJsonArraySerialization (line 695) | @Test
method testJsonArrayDeserialization (line 704) | @Test
method testJsonObjectSerialization (line 716) | @Test
method testJsonObjectDeserialization (line 724) | @Test
method testJsonNullDeserialization (line 738) | @Test
method testJsonElementTypeMismatch (line 744) | @Test
class ClassWithBigDecimal (line 755) | private static class ClassWithBigDecimal {
method ClassWithBigDecimal (line 758) | ClassWithBigDecimal(String value) {
method getExpectedJson (line 762) | String getExpectedJson() {
class ClassWithBigInteger (line 767) | private static class ClassWithBigInteger {
method ClassWithBigInteger (line 770) | ClassWithBigInteger(String value) {
method getExpectedJson (line 774) | String getExpectedJson() {
method testPropertiesSerialization (line 779) | @Test
method testPropertiesDeserialization (line 788) | @Test
method testTreeSetSerialization (line 795) | @Test
method testTreeSetDeserialization (line 803) | @Test
method testStringBuilderSerialization (line 811) | @SuppressWarnings("UnnecessaryStringBuilder") // TODO: b/287969247 - r...
method testStringBuilderDeserialization (line 819) | @Test
method testStringBufferSerialization (line 825) | @Test
method testStringBufferDeserialization (line 833) | @Test
method testJavaTimeDuration (line 839) | @Test
method testJavaTimeDurationWithUnknownFields (line 846) | @Test
method testJavaTimeInstant (line 853) | @Test
method testJavaTimeLocalDate (line 860) | @Test
method testJavaTimeLocalTime (line 867) | @Test
method testJavaTimeLocalDateTime (line 874) | @Test
method testJavaTimeMonthDay (line 883) | @Test
method testJavaTimeOffsetDateTime (line 890) | @Test
method testJavaTimeOffsetTime (line 902) | @Test
method testJavaTimePeriod (line 911) | @Test
method testJavaTimeYear (line 918) | @Test
method testJavaTimeYearMonth (line 925) | @Test
method testJavaTimeZoneOffset (line 932) | @Test
method testJavaTimeZoneRegion (line 939) | @Test
method testJavaTimeZonedDateTimeWithZoneOffset (line 946) | @Test
method testJavaTimeZonedDateTimeWithZoneId (line 959) | @Test
method testJavaTimeZonedDateTimeWithZoneIdThatHasAdapter (line 977) | @Test
method roundTrip (line 1024) | private void roundTrip(Object value, String expectedJson) {
method roundTrip (line 1028) | private void roundTrip(Object value, Class<?> valueClass, String expec...
method roundTrip (line 1035) | private void roundTrip(Gson customGson, Object value, Class<?> valueCl...
method checkReflectiveTypeAdapterFactory (line 1044) | private void checkReflectiveTypeAdapterFactory(Object value, String ex...
class MyClassTypeAdapter (line 1065) | private static class MyClassTypeAdapter extends TypeAdapter<Class<?>> {
method write (line 1066) | @Override
method read (line 1071) | @Override
class NumberAsStringAdapter (line 1082) | static class NumberAsStringAdapter extends TypeAdapter<Number> {
method NumberAsStringAdapter (line 1085) | NumberAsStringAdapter(Class<? extends Number> type) throws Exception {
method write (line 1089) | @Override
method read (line 1094) | @Override
FILE: gson/src/test/java/com/google/gson/functional/DelegateTypeAdapterTest.java
class DelegateTypeAdapterTest (line 39) | public class DelegateTypeAdapterTest {
method setUp (line 44) | @Before
method testDelegateInvoked (line 50) | @Test
method testDelegateInvokedOnStrings (line 64) | @Test
class StatsTypeAdapterFactory (line 74) | private static class StatsTypeAdapterFactory implements TypeAdapterFac...
method create (line 78) | @Override
FILE: gson/src/test/java/com/google/gson/functional/EnumTest.java
class EnumTest (line 50) | public class EnumTest {
method setUp (line 54) | @Before
method testTopLevelEnumSerialization (line 59) | @Test
method testTopLevelEnumDeserialization (line 65) | @Test
method testCollectionOfEnumsSerialization (line 71) | @Test
method testCollectionOfEnumsDeserialization (line 84) | @Test
method testClassWithEnumFieldSerialization (line 93) | @Test
method testClassWithEnumFieldDeserialization (line 99) | @Test
type MyEnum (line 107) | private static enum MyEnum {
class ClassWithEnumFields (line 112) | private static class ClassWithEnumFields {
method getExpectedJson (line 116) | String getExpectedJson() {
method testEnumSubclass (line 122) | @Test
method testEnumSubclassWithRegisteredTypeAdapter (line 139) | @Test
method testEnumSubclassAsParameterizedType (line 156) | @Test
method testEnumCaseMapping (line 171) | @Test
method testEnumSet (line 177) | @Test
method testEnumMap (line 189) | @Test
type Roshambo (line 202) | private enum Roshambo {
method defeats (line 204) | @Override
method defeats (line 210) | @Override
method defeats (line 216) | @Override
method defeats (line 222) | @SuppressWarnings("unused")
class MyEnumTypeAdapter (line 226) | private static class MyEnumTypeAdapter
method serialize (line 228) | @Override
method deserialize (line 233) | @Override
type Gender (line 240) | private enum Gender {
method testEnumClassWithFields (line 248) | @Test
type Color (line 255) | private enum Color {
method Color (line 262) | private Color(String value, int index) {
method testEnumToStringRead (line 268) | @Test
type CustomToString (line 278) | private enum CustomToString {
method toString (line 281) | @Override
method testEnumToStringReadInterchanged (line 288) | @Test
type InterchangedToString (line 296) | private enum InterchangedToString {
method InterchangedToString (line 302) | InterchangedToString(String toString) {
method toString (line 306) | @Override
method testJdkEnum (line 317) | @Test
FILE: gson/src/test/java/com/google/gson/functional/EnumWithObfuscatedTest.java
class EnumWithObfuscatedTest (line 32) | public class EnumWithObfuscatedTest {
method setUp (line 35) | @Before
type Gender (line 40) | public enum Gender {
method testEnumClassWithObfuscated (line 48) | @Test
FILE: gson/src/test/java/com/google/gson/functional/EscapingTest.java
class EscapingTest (line 35) | public class EscapingTest {
method setUp (line 38) | @Before
method testEscapingQuotesInStringArray (line 43) | @Test
method testEscapeAllHtmlCharacters (line 52) | @Test
method testEscapingObjectFields (line 65) | @Test
method testGsonAcceptsEscapedAndNonEscapedJsonDeserialization (line 77) | @Test
method testGsonDoubleDeserialization (line 92) | @Test
FILE: gson/src/test/java/com/google/gson/functional/ExclusionStrategyFunctionalTest.java
class ExclusionStrategyFunctionalTest (line 41) | public class ExclusionStrategyFunctionalTest {
method shouldSkipField (line 44) | @Override
method shouldSkipClass (line 49) | @Override
method setUp (line 57) | @Before
method testExclusionStrategySerialization (line 62) | @Test
method testExclusionStrategySerializationDoesNotImpactDeserialization (line 71) | @Test
method testExclusionStrategyDeserialization (line 81) | @Test
method testExclusionStrategySerializationDoesNotImpactSerialization (line 97) | @Test
method testExclusionStrategyWithMode (line 106) | @Test
method testExcludeTopLevelClassSerialization (line 126) | @Test
method testExcludeTopLevelClassSerializationDoesNotImpactDeserialization (line 135) | @Test
method testExcludeTopLevelClassDeserialization (line 148) | @Test
method testExcludeTopLevelClassDeserializationDoesNotImpactSerialization (line 159) | @Test
method createGson (line 171) | private static Gson createGson(ExclusionStrategy exclusionStrategy, bo...
class SampleObjectForTest (line 187) | private static class SampleObjectForTest {
method SampleObjectForTest (line 192) | SampleObjectForTest() {
method SampleObjectForTest (line 196) | SampleObjectForTest(int annotatedField, String stringField, long lon...
class MyExclusionStrategy (line 203) | private static final class MyExclusionStrategy implements ExclusionStr...
method MyExclusionStrategy (line 206) | private MyExclusionStrategy(Class<?> typeToSkip) {
method shouldSkipClass (line 210) | @Override
method shouldSkipField (line 215) | @Override
FILE: gson/src/test/java/com/google/gson/functional/ExposeFieldsTest.java
class ExposeFieldsTest (line 35) | public class ExposeFieldsTest {
method setUp (line 39) | @Before
method testNullExposeFieldSerialization (line 48) | @Test
method testArrayWithOneNullExposeFieldObjectSerialization (line 56) | @Test
method testExposeAnnotationSerialization (line 76) | @Test
method testExposeAnnotationDeserialization (line 82) | @Test
method testNoExposedFieldSerialization (line 92) | @Test
method testNoExposedFieldDeserialization (line 100) | @Test
method testExposedInterfaceFieldSerialization (line 109) | @Test
method testExposedInterfaceFieldDeserialization (line 118) | @Test
class ClassWithExposedFields (line 126) | private static class ClassWithExposedFields {
method ClassWithExposedFields (line 141) | ClassWithExposedFields(Integer a, Integer b) {
method ClassWithExposedFields (line 145) | ClassWithExposedFields(Integer a, Integer b, long c, double d, char ...
method getExpectedJson (line 153) | String getExpectedJson() {
class ClassWithNoExposedFields (line 164) | private static class ClassWithNoExposedFields {
type SomeInterface (line 169) | private static interface SomeInterface {
class SomeObject (line 173) | private static class SomeObject implements SomeInterface {
class SomeInterfaceInstanceCreator (line 177) | private static class SomeInterfaceInstanceCreator implements InstanceC...
method createInstance (line 178) | @Override
class ClassWithInterfaceField (line 184) | private static class ClassWithInterfaceField {
method ClassWithInterfaceField (line 187) | ClassWithInterfaceField(SomeInterface interfaceField) {
FILE: gson/src/test/java/com/google/gson/functional/FieldExclusionTest.java
class FieldExclusionTest (line 33) | public class FieldExclusionTest {
method setUp (line 38) | @Before
method testDefaultInnerClassExclusion (line 43) | @Test
method testInnerClassExclusion (line 56) | @Test
method testDefaultNestedStaticClassIncluded (line 64) | @Test
class Outer (line 77) | private static class Outer {
class Inner (line 79) | @SuppressWarnings("ClassCanBeStatic")
method Inner (line 81) | Inner(String value) {
class NestedClass (line 87) | private static class NestedClass {
method NestedClass (line 90) | NestedClass(String value) {
method toJson (line 94) | String toJson() {
FILE: gson/src/test/java/com/google/gson/functional/FieldNamingTest.java
class FieldNamingTest (line 33) | public final class FieldNamingTest {
method testIdentity (line 34) | @Test
method testUpperCamelCase (line 44) | @Test
method testUpperCamelCaseWithSpaces (line 54) | @Test
method testUpperCaseWithUnderscores (line 64) | @Test
method testLowerCaseWithUnderscores (line 74) | @Test
method testLowerCaseWithDashes (line 84) | @Test
method getGsonWithNamingPolicy (line 94) | private static Gson getGsonWithNamingPolicy(FieldNamingPolicy fieldNam...
class TestNames (line 99) | @SuppressWarnings({"unused", "MemberName", "ConstantField"})
FILE: gson/src/test/java/com/google/gson/functional/FormattingStyleTest.java
class FormattingStyleTest (line 38) | @RunWith(JUnit4.class)
method createInput (line 42) | private static Map<String, List<Integer>> createInput() {
method buildExpected (line 48) | private static String buildExpected(String newline, String indent, boo...
method testDefault (line 65) | @Test
method testVariousCombinationsParse (line 72) | @Test
method toJson (line 96) | private static String toJson(Object obj, FormattingStyle style) {
method testFormatCompact (line 100) | @Test
method testFormatPretty (line 109) | @Test
method testFormatPrettySingleLine (line 125) | @Test
method testFormat (line 135) | @Test
method testCompactToPretty (line 158) | @Test
method testPrettyToCompact (line 172) | @Test
method testStyleValidations (line 182) | @Test
FILE: gson/src/test/java/com/google/gson/functional/GsonVersionDiagnosticsTest.java
class GsonVersionDiagnosticsTest (line 35) | public class GsonVersionDiagnosticsTest {
method setUp (line 42) | @Before
method testVersionPattern (line 62) | @Test
method testAssertionErrorInSerializationPrintsVersion (line 68) | @Test
method testAssertionErrorInDeserializationPrintsVersion (line 74) | @Test
method ensureAssertionErrorPrintsGsonVersion (line 82) | private static void ensureAssertionErrorPrintsGsonVersion(AssertionErr...
class TestType (line 94) | private static final class TestType {
FILE: gson/src/test/java/com/google/gson/functional/InheritanceTest.java
class InheritanceTest (line 50) | public class InheritanceTest {
method setUp (line 53) | @Before
method testSubClassSerialization (line 58) | @Test
method testSubClassDeserialization (line 67) | @Test
method testClassWithBaseFieldSerialization (line 78) | @Test
method testClassWithBaseArrayFieldSerialization (line 86) | @Test
method testClassWithBaseCollectionFieldSerialization (line 98) | @Test
method testBaseSerializedAsSub (line 112) | @Test
method testBaseSerializedAsSubForToJsonMethod (line 119) | @Test
method testBaseSerializedAsBaseWhenSpecifiedWithExplicitType (line 126) | @Test
method testBaseSerializedAsBaseWhenSpecifiedWithExplicitTypeForToJsonMethod (line 134) | @Test
method testBaseSerializedAsSubWhenSpecifiedWithExplicitType (line 142) | @Test
method testBaseSerializedAsSubWhenSpecifiedWithExplicitTypeForToJsonMethod (line 149) | @Test
class SubTypeOfNested (line 156) | private static class SubTypeOfNested extends Nested {
method SubTypeOfNested (line 159) | SubTypeOfNested(BagOfPrimitives primitive1, BagOfPrimitives primitiv...
method appendFields (line 163) | @Override
method testSubInterfacesOfCollectionSerialization (line 170) | @Test
method testSubInterfacesOfCollectionDeserialization (line 198) | @Test
class ClassWithSubInterfacesOfCollection (line 212) | private static class ClassWithSubInterfacesOfCollection {
method ClassWithSubInterfacesOfCollection (line 218) | ClassWithSubInterfacesOfCollection(
method listContains (line 226) | boolean listContains(int... values) {
method queueContains (line 235) | boolean queueContains(long... values) {
method setContains (line 244) | boolean setContains(float... values) {
method sortedSetContains (line 253) | boolean sortedSetContains(char... values) {
method getExpectedJson (line 262) | String getExpectedJson() {
method append (line 277) | @CanIgnoreReturnValue
FILE: gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java
class InstanceCreatorTest (line 41) | public class InstanceCreatorTest {
method testInstanceCreatorReturnsBaseType (line 43) | @Test
method testInstanceCreatorReturnsSubTypeForTopLevelObject (line 54) | @Test
method testInstanceCreatorReturnsSubTypeForField (line 70) | @Test
method testInstanceCreatorForCollectionType (line 83) | @Test
method testInstanceCreatorForParametrizedType (line 94) | @SuppressWarnings("unchecked")
FILE: gson/src/test/java/com/google/gson/functional/InterfaceTest.java
class InterfaceTest (line 31) | public class InterfaceTest {
method setUp (line 37) | @Before
method testSerializingObjectImplementingInterface (line 43) | @Test
method testSerializingInterfaceObjectField (line 48) | @Test
type TestObjectInterface (line 54) | private static interface TestObjectInterface {
class TestObject (line 58) | private static class TestObject implements TestObjectInterface {
method TestObject (line 62) | private TestObject(String value) {
class TestObjectWrapper (line 67) | private static class TestObjectWrapper {
method TestObjectWrapper (line 71) | private TestObjectWrapper(TestObjectInterface obj) {
FILE: gson/src/test/java/com/google/gson/functional/InternationalizationTest.java
class InternationalizationTest (line 30) | public class InternationalizationTest {
method setUp (line 33) | @Before
method testStringsWithUnicodeChineseCharactersSerialization (line 38) | @Test
method testStringsWithUnicodeChineseCharactersDeserialization (line 46) | @Test
method testStringsWithUnicodeChineseCharactersEscapedDeserialization (line 54) | @Test
method testSupplementaryUnicodeSerialization (line 60) | @Test
method testSupplementaryUnicodeDeserialization (line 68) | @Test
method testSupplementaryUnicodeEscapedDeserialization (line 76) | @Test
FILE: gson/src/test/java/com/google/gson/functional/Java17RecordTest.java
class Java17RecordTest (line 46) | @RunWith(JUnit4.class)
method testFirstNameIsChosenForSerialization (line 50) | @Test
method testMultipleNamesDeserializedCorrectly (line 57) | @Test
method testMultipleNamesInTheSameString (line 70) | @Test
method testSerializedNameOnAccessor (line 88) | @Test
method testFieldNamingStrategy (line 106) | @Test
method testUnknownJsonProperty (line 116) | @Test
method testDuplicateJsonProperties (line 124) | @Test
method testConstructorRuns (line 133) | @Test
method testThrowingConstructor (line 147) | @Test
method testAccessorIsCalled (line 172) | @Test
method testThrowingAccessor (line 186) | @Test
method testEmptyRecord (line 207) | @Test
method testRecordNull (line 219) | @Test
method testPrimitiveDefaultValues (line 228) | @Test
method testPrimitiveJsonNullValue (line 235) | @Test
method testPrimitiveAdapterNullValue (line 251) | @Test
method testObjectDefaultValue (line 294) | @Test
method testStaticFieldSerialization (line 307) | @Test
method testStaticFieldDeserialization (line 328) | @Test
method testExposeAnnotation (line 356) | @Test
method testFieldExclusionStrategy (line 365) | @Test
method testJsonAdapterAnnotation (line 388) | @Test
method testClassReflectionFilter (line 409) | @Test
method testReflectionFilterBlockInaccessible (line 432) | @Test
method testRecordBaseClass (line 467) | @Test
FILE: gson/src/test/java/com/google/gson/functional/JavaUtilConcurrentAtomicTest.java
class JavaUtilConcurrentAtomicTest (line 36) | public class JavaUtilConcurrentAtomicTest {
method setUp (line 39) | @Before
method testAtomicBoolean (line 44) | @Test
method testAtomicInteger (line 52) | @Test
method testAtomicLong (line 60) | @Test
method testAtomicLongWithStringSerializationPolicy (line 68) | @Test
method testAtomicIntegerArray (line 78) | @Test
method testAtomicLongArray (line 89) | @Test
method testAtomicLongArrayWithStringSerializationPolicy (line 100) | @Test
class AtomicLongHolder (line 113) | private static class AtomicLongHolder {
FILE: gson/src/test/java/com/google/gson/functional/JavaUtilTest.java
class JavaUtilTest (line 28) | public class JavaUtilTest {
method setUp (line 31) | @Before
method testCurrency (line 36) | @Test
class CurrencyHolder (line 49) | private static class CurrencyHolder {
method testProperties (line 53) | @Test
FILE: gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnClassesTest.java
class JsonAdapterAnnotationOnClassesTest (line 46) | @SuppressWarnings("ClassNamedLikeTypeParameter") // for dummy classes A,...
method testJsonAdapterInvoked (line 49) | @Test
method testJsonAdapterFactoryInvoked (line 68) | @Test
method testRegisteredAdapterOverridesJsonAdapter (line 77) | @Test
method testRegisteredSerializerOverridesJsonAdapter (line 97) | @Test
method testRegisteredDeserializerOverridesJsonAdapter (line 109) | @Test
method testIncorrectTypeAdapterFails (line 119) | @Test
method testSuperclassTypeAdapterNotInvoked (line 126) | @Test
method testNullSafeObject (line 132) | @Test
method testFactoryReturningNull (line 153) | @Test
class WithNullReturningFactory (line 179) | @JsonAdapter(value = WithNullReturningFactory.NullReturningFactory.cla...
method WithNullReturningFactory (line 183) | WithNullReturningFactory(T t) {
class NullReturningFactory (line 187) | static class NullReturningFactory implements TypeAdapterFactory {
method create (line 188) | @Override
class A (line 221) | @JsonAdapter(A.JsonAdapter.class)
method A (line 225) | A(String value) {
class JsonAdapter (line 229) | static final class JsonAdapter extends TypeAdapter<A> {
method write (line 230) | @Override
method read (line 235) | @Override
class C (line 243) | @JsonAdapter(C.JsonAdapterFactory.class)
method C (line 247) | C(String value) {
class JsonAdapterFactory (line 251) | static final class JsonAdapterFactory implements TypeAdapterFactory {
method create (line 252) | @Override
class B (line 271) | private static final class B extends A {
method B (line 272) | B(String value) {
class ClassWithIncorrectJsonAdapter (line 279) | @JsonAdapter(A.JsonAdapter.class)
method ClassWithIncorrectJsonAdapter (line 284) | ClassWithIncorrectJsonAdapter(String value) {
class User (line 290) | @JsonAdapter(UserJsonAdapter.class)
method User (line 295) | User(String firstName, String lastName) {
class UserJsonAdapter (line 301) | private static class UserJsonAdapter extends TypeAdapter<User> {
method write (line 302) | @Override
method read (line 311) | @Override
class NullableClass (line 323) | @JsonAdapter(value = NullableClassJsonAdapter.class)
class NullableClassJsonAdapter (line 326) | private static class NullableClassJsonAdapter extends TypeAdapter<Null...
method write (line 327) | @Override
method read (line 332) | @Override
type Foo (line 339) | @JsonAdapter(FooJsonAdapter.class)
class FooJsonAdapter (line 345) | private static class FooJsonAdapter extends TypeAdapter<Foo> {
method write (line 346) | @Override
method read (line 351) | @Override
method testIncorrectJsonAdapterType (line 357) | @Test
class WithInvalidAdapterClass (line 371) | @JsonAdapter(Integer.class)
method testDelegatingAdapterFactory (line 382) | @Test
class WithDelegatingFactory (line 399) | @JsonAdapter(WithDelegatingFactory.Factory.class)
method WithDelegatingFactory (line 403) | WithDelegatingFactory(T f) {
class Factory (line 407) | static class Factory implements TypeAdapterFactory {
method create (line 408) | @Override
method testDelegatingAdapterFactory_Delayed (line 445) | @Test
class WithDelayedDelegatingFactory (line 455) | @JsonAdapter(WithDelayedDelegatingFactory.Factory.class)
method WithDelayedDelegatingFactory (line 459) | WithDelayedDelegatingFactory(String f) {
class Factory (line 463) | static class Factory implements TypeAdapterFactory {
method create (line 464) | @Override
method testDelegating_SameFactoryClass (line 502) | @Test
method testDelegating_SameFactoryInstance (line 525) | @Test
method testDelegating_SameFactoryClass_OnClassAndField (line 560) | @Test
method testDelegating_SameFactoryInstance_OnClassAndField (line 601) | @Test
class WithDelegatingFactoryOnClassAndField (line 642) | @JsonAdapter(WithDelegatingFactoryOnClassAndField.Factory.class)
method WithDelegatingFactoryOnClassAndField (line 649) | WithDelegatingFactoryOnClassAndField(String f) {
class Factory (line 653) | static class Factory implements TypeAdapterFactory {
method create (line 654) | @Override
method testJsonSerializer (line 684) | @Test
class WithJsonSerializer (line 696) | @JsonAdapter(WithJsonSerializer.Serializer.class)
class Serializer (line 700) | static class Serializer implements JsonSerializer<WithJsonSerializer> {
method serialize (line 701) | @Override
method testJsonDeserializer (line 710) | @Test
class WithJsonDeserializer (line 723) | @JsonAdapter(WithJsonDeserializer.Deserializer.class)
method WithJsonDeserializer (line 727) | WithJsonDeserializer(String f) {
class Deserializer (line 731) | static class Deserializer implements JsonDeserializer<WithJsonDeseri...
method deserialize (line 732) | @Override
method testAdapterCreatedByInstanceCreator (line 744) | @Test
class CreatedByInstanceCreator (line 758) | @JsonAdapter(CreatedByInstanceCreator.Serializer.class)
class Serializer (line 760) | static class Serializer implements JsonSerializer<CreatedByInstanceC...
method Serializer (line 763) | @SuppressWarnings("unused")
method Serializer (line 768) | Serializer(String value) {
method serialize (line 772) | @Override
method testAdapterCreatedByJdkUnsafe (line 781) | @Test
class CreatedByJdkUnsafe (line 787) | @JsonAdapter(CreatedByJdkUnsafe.Serializer.class)
class Serializer (line 789) | static class Serializer implements JsonSerializer<CreatedByJdkUnsafe> {
method Serializer (line 794) | @SuppressWarnings("unused")
method serialize (line 799) | @Override
FILE: gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnFieldsTest.java
class JsonAdapterAnnotationOnFieldsTest (line 46) | public final class JsonAdapterAnnotationOnFieldsTest {
method testClassAnnotationAdapterTakesPrecedenceOverDefault (line 47) | @Test
method testClassAnnotationAdapterFactoryTakesPrecedenceOverDefault (line 56) | @Test
method testRegisteredTypeAdapterTakesPrecedenceOverClassAnnotationAdapter (line 65) | @Test
method testFieldAnnotationTakesPrecedenceOverRegisteredTypeAdapter (line 75) | @Test
method testFieldAnnotationTakesPrecedenceOverClassAnnotation (line 99) | @Test
class Gadget (line 108) | private static final class Gadget {
method Gadget (line 112) | Gadget(Part part) {
class Gizmo (line 117) | private static final class Gizmo {
method Gizmo (line 121) | Gizmo(Part part) {
class Part (line 126) | private static final class Part {
method Part (line 129) | Part(String name) {
class PartJsonFieldAnnotationAdapter (line 134) | private static class PartJsonFieldAnnotationAdapter extends TypeAdapte...
method write (line 135) | @Override
method read (line 140) | @Override
class GizmoPartTypeAdapterFactory (line 147) | private static class GizmoPartTypeAdapterFactory implements TypeAdapte...
method create (line 148) | @Override
class Computer (line 166) | private static final class Computer {
method Computer (line 169) | Computer(User user) {
class User (line 174) | @JsonAdapter(UserClassAnnotationAdapter.class)
method User (line 178) | private User(String name) {
class UserClassAnnotationAdapter (line 183) | private static class UserClassAnnotationAdapter extends TypeAdapter<Us...
method write (line 184) | @Override
method read (line 189) | @Override
class Computer2 (line 196) | private static final class Computer2 {
method Computer2 (line 201) | Computer2(User user) {
class UserFieldAnnotationAdapter (line 206) | private static final class UserFieldAnnotationAdapter extends TypeAdap...
method write (line 207) | @Override
method read (line 212) | @Override
class RegisteredUserAdapter (line 219) | private static final class RegisteredUserAdapter extends TypeAdapter<U...
method write (line 220) | @Override
method read (line 225) | @Override
method testJsonAdapterInvokedOnlyForAnnotatedFields (line 232) | @Test
class GadgetWithTwoParts (line 241) | private static final class GadgetWithTwoParts {
method GadgetWithTwoParts (line 247) | @SuppressWarnings("unused")
method testJsonAdapterWrappedInNullSafeAsRequested (line 254) | @Test
class GadgetWithOptionalPart (line 266) | private static final class GadgetWithOptionalPart {
method GadgetWithOptionalPart (line 270) | private GadgetWithOptionalPart(Part part) {
method testNonPrimitiveFieldAnnotationTakesPrecedenceOverDefault (line 276) | @Test
method testPrimitiveFieldAnnotationTakesPrecedenceOverDefault (line 286) | @Test
class GadgetWithPrimitivePart (line 295) | private static final class GadgetWithPrimitivePart {
method GadgetWithPrimitivePart (line 299) | private GadgetWithPrimitivePart(long part) {
class LongToStringTypeAdapterFactory (line 304) | private static final class LongToStringTypeAdapterFactory implements T...
method write (line 307) | @Override
method read (line 312) | @Override
method create (line 318) | @SuppressWarnings("unchecked")
method testFieldAnnotationWorksForParameterizedType (line 334) | @Test
class Gizmo2 (line 343) | private static final class Gizmo2 {
method Gizmo2 (line 347) | Gizmo2(List<Part> part) {
class Gizmo2PartTypeAdapterFactory (line 352) | private static class Gizmo2PartTypeAdapterFactory implements TypeAdapt...
method create (line 353) | @Override
method testOverwriteBuiltIn (line 375) | @Test
class BuiltInOverwriting (line 386) | private static class BuiltInOverwriting {
class JsonElementAdapter (line 391) | private static class JsonElementAdapter extends TypeAdapter<JsonElemen...
method read (line 394) | @Override
method write (line 402) | @Override
method testExcludeSerializePrecedence (line 412) | @Test
method testExcludeDeserializePrecedence (line 449) | @Test
method testExcludePrecedence (line 490) | @Test
class DelegatingAndOverwriting (line 522) | private static class DelegatingAndOverwriting {
class DelegatingAdapterFactory (line 533) | static class DelegatingAdapterFactory implements TypeAdapterFactory {
method create (line 534) | @Override
method testDelegatingAdapterFactory (line 546) | @Test
class WithDelegatingFactory (line 562) | private static class WithDelegatingFactory<T> {
class Factory (line 568) | static class Factory implements TypeAdapterFactory {
method create (line 569) | @SuppressWarnings("unchecked")
method testDelegatingAdapterFactory_Delayed (line 596) | @Test
class WithDelayedDelegatingFactory (line 608) | @SuppressWarnings("SameNameButDifferent")
class Factory (line 613) | static class Factory implements TypeAdapterFactory {
method create (line 614) | @SuppressWarnings("unchecked")
method testGetAdapterDelegation (line 645) | @Test
class GetAdapterDelegation (line 655) | private static class GetAdapterDelegation {
method GetAdapterDelegation (line 661) | GetAdapterDelegation(String f) {
class Factory (line 665) | static class Factory implements TypeAdapterFactory {
method create (line 666) | @SuppressWarnings("unchecked")
method testJsonSerializer (line 689) | @Test
class WithJsonSerializer (line 701) | private static class WithJsonSerializer {
class Serializer (line 705) | static class Serializer implements JsonSerializer<List<Integer>> {
method serialize (line 706) | @Override
method testJsonDeserializer (line 715) | @Test
class WithJsonDeserializer (line 727) | private static class WithJsonDeserializer {
method WithJsonDeserializer (line 731) | WithJsonDeserializer(List<Integer> f) {
class Deserializer (line 735) | static class Deserializer implements JsonDeserializer<List<Integer>> {
method deserialize (line 736) | @Override
FILE: gson/src/test/java/com/google/gson/functional/JsonAdapterSerializerDeserializerTest.java
class JsonAdapterSerializerDeserializerTest (line 43) | public final class JsonAdapterSerializerDeserializerTest {
method testJsonSerializerDeserializerBasedJsonAdapterOnFields (line 45) | @Test
class Computer (line 58) | private static final class Computer {
method Computer (line 71) | Computer(User user1, User user2, User user3) {
class User (line 78) | private static final class User {
method User (line 81) | private User(String name) {
class UserSerializer (line 86) | private static final class UserSerializer implements JsonSerializer<Us...
method serialize (line 87) | @Override
class UserDeserializer (line 93) | private static final class UserDeserializer implements JsonDeserialize...
method deserialize (line 94) | @Override
class UserSerializerDeserializer (line 101) | private static final class UserSerializerDeserializer
method serialize (line 103) | @Override
method deserialize (line 108) | @Override
method testJsonSerializerDeserializerBasedJsonAdapterOnClass (line 115) | @Test
class Computer2 (line 124) | private static final class Computer2 {
method Computer2 (line 127) | Computer2(User2 user) {
class User2 (line 132) | @JsonAdapter(UserSerializerDeserializer2.class)
method User2 (line 136) | private User2(String name) {
class UserSerializerDeserializer2 (line 141) | private static final class UserSerializerDeserializer2
method serialize (line 143) | @Override
method deserialize (line 148) | @Override
method testDifferentJsonAdaptersForGenericFieldsOfSameRawType (line 155) | @Test
class Container (line 164) | private static final class Container {
method Container (line 173) | Container(String a, int b) {
class Base (line 179) | private static final class Base<T> {
method Base (line 183) | Base(T value) {
class BaseStringAdapter (line 188) | private static final class BaseStringAdapter implements JsonSerializer...
method serialize (line 189) | @Override
class BaseIntegerAdapter (line 196) | private static final class BaseIntegerAdapter implements JsonSerialize...
method serialize (line 197) | @Override
method testJsonAdapterNullSafe (line 204) | @Test
class WithNullSafe (line 243) | @SuppressWarnings("MemberName")
method WithNullSafe (line 259) | WithNullSafe(User userS, User userSN, User userD, User userDN) {
FILE: gson/src/test/java/com/google/gson/functional/JsonParserTest.java
class JsonParserTest (line 47) | public class JsonParserTest {
method setUp (line 50) | @Before
method testParseInvalidJson (line 55) | @Test
method testDeserializingCustomTree (line 61) | @Test
method testBadTypeForDeserializingCustomTree (line 71) | @Test
method testBadFieldTypeForCustomDeserializerCustomTree (line 82) | @Test
method testBadFieldTypeForDeserializingCustomTree (line 95) | @Test
method testChangingCustomTreeAndDeserializing (line 111) | @Test
method testExtraCommasInArrays (line 124) | @Test
method testExtraCommasInMaps (line 133) | @Test
FILE: gson/src/test/java/com/google/gson/functional/JsonTreeTest.java
class JsonTreeTest (line 39) | public class JsonTreeTest {
method setUp (line 42) | @Before
method testToJsonTree (line 47) | @Test
method testToJsonTreeObjectType (line 61) | @Test
method testJsonTreeToString (line 75) | @Test
method testJsonTreeNull (line 84) | @Test
method assertContains (line 91) | private static void assertContains(JsonObject json, JsonPrimitive chil...
class SubTypeOfBagOfPrimitives (line 103) | private static class SubTypeOfBagOfPrimitives extends BagOfPrimitives {
method SubTypeOfBagOfPrimitives (line 107) | SubTypeOfBagOfPrimitives(long l, int i, boolean b, String string, fl...
FILE: gson/src/test/java/com/google/gson/functional/LeniencyTest.java
class LeniencyTest (line 29) | public class LeniencyTest {
method setUp (line 33) | @SuppressWarnings({"deprecation", "InlineMeInliner"}) // for GsonBuild...
method testLenientFromJson (line 39) | @Test
FILE: gson/src/test/java/com/google/gson/functional/MapAsArrayTypeAdapterTest.java
class MapAsArrayTypeAdapterTest (line 33) | public class MapAsArrayTypeAdapterTest {
method testSerializeComplexMapWithTypeAdapter (line 35) | @Test
method testTwoTypesCollapseToOneSerialize (line 60) | @Test
method testTwoTypesCollapseToOneDeserialize (line 73) | @Test
method testMultipleEnableComplexKeyRegistrationHasNoEffect (line 83) | @Test
method testMapWithTypeVariableSerialization (line 100) | @Test
method testMapWithTypeVariableDeserialization (line 110) | @Test
class Point (line 122) | static class Point {
method Point (line 126) | Point(int x, int y) {
method Point (line 131) | Point() {}
method equals (line 133) | @Override
method hashCode (line 138) | @Override
method toString (line 143) | @Override
class PointWithProperty (line 149) | static class PointWithProperty<T> {
FILE: gson/src/test/java/com/google/gson/functional/MapTest.java
class MapTest (line 61) | public class MapTest {
method setUp (line 64) | @Before
method testMapSerialization (line 69) | @Test
method testMapDeserialization (line 80) | @Test
method testObjectMapSerialization (line 89) | @Test
method testMapSerializationEmpty (line 99) | @Test
method testMapDeserializationEmpty (line 107) | @Test
method testMapSerializationWithNullValue (line 114) | @Test
method testMapDeserializationWithNullValue (line 125) | @Test
method testMapSerializationWithNullValueButSerializeNulls (line 133) | @Test
method testMapSerializationWithNullKey (line 144) | @Test
method testMapDeserializationWithNullKey (line 154) | @Test
method testMapSerializationWithIntegerKeys (line 168) | @Test
method testMapDeserializationWithIntegerKeys (line 178) | @Test
method testMapDeserializationWithUnquotedIntegerKeys (line 187) | @Test
method testMapDeserializationWithLongKeys (line 196) | @Test
method testMapDeserializationWithUnquotedLongKeys (line 207) | @Test
method testMapStringKeyDeserialization (line 218) | @Test
method testMapStringSupertypeKeyDeserialization (line 233) | @Test
method testMapNonStringKeyDeserialization (line 247) | @Test
method testHashMapDeserialization (line 260) | @Test
method testSortedMap (line 269) | @Test
method testConcurrentMap (line 278) | @Test
method testConcurrentHashMap (line 289) | @Test
method testConcurrentNavigableMap (line 300) | @Test
method testConcurrentSkipListMap (line 311) | @Test
method testParameterizedMapSubclassSerialization (line 322) | @Test
class MyParameterizedMap (line 331) | @SuppressWarnings({"unused", "serial"})
method MyParameterizedMap (line 335) | MyParameterizedMap(int foo) {
method testMapSubclassSerialization (line 340) | @Test
method testMapStandardSubclassDeserialization (line 348) | @Test
method testMapSubclassDeserialization (line 357) | @Test
method testCustomSerializerForSpecificMapType (line 369) | @Test
class MapWithoutNoArgsConstructor (line 394) | private static class MapWithoutNoArgsConstructor<K, V> extends Abstrac...
method MapWithoutNoArgsConstructor (line 396) | MapWithoutNoArgsConstructor(int unused) {}
method put (line 398) | @Override
method entrySet (line 403) | @Override
method testMapWithoutNoArgsConstructor (line 413) | @Test
class ClassWithAMap (line 440) | private static class ClassWithAMap {
method testMapSerializationWithNullValues (line 445) | @Test
method testMapSerializationWithNullValuesSerialized (line 456) | @Test
method testMapSerializationWithWildcardValues (line 467) | @Test
method testMapDeserializationWithWildcardValues (line 478) | @Test
class MyMap (line 486) | private static class MyMap extends LinkedHashMap<String, String> {
method testMapOfMapSerialization (line 494) | @Test
method testMapOfMapDeserialization (line 508) | @Test
method testMapWithQuotes (line 519) | @Test
method testWriteMapsWithEmptyStringKey (line 528) | @Test
method testReadMapsWithEmptyStringKey (line 535) | @Test
method testSerializeMaps (line 543) | @Test
method testInterfaceTypeMap (line 575) | @Test
method testInterfaceTypeMapWithSerializer (line 595) | @Test
method testGeneralMapField (line 625) | @Test
method testComplexKeysSerialization (line 641) | @Test
method testComplexKeysDeserialization (line 651) | @Test
method testStringKeyDeserialization (line 662) | @Test
method testNumberKeyDeserialization (line 671) | @Test
method testBooleanKeyDeserialization (line 680) | @Test
method testMapDeserializationWithDuplicateKeys (line 689) | @Test
method testSerializeMapOfMaps (line 696) | @Test
method testDeserializeMapOfMaps (line 707) | @Test
method newMap (line 718) | private static <K, V> Map<K, V> newMap(K key1, V value1, K key2, V val...
method testMapNamePromotionWithJsonElementReader (line 725) | @Test
class Point (line 734) | static class Point {
method Point (line 738) | Point(int x, int y) {
method equals (line 743) | @Override
method hashCode (line 748) | @Override
method toString (line 753) | @Override
class MapClass (line 759) | static final class MapClass {
method addBase (line 763) | public final void addBase(String name, TestTypes.Base value) {
method addSub (line 767) | public final void addSub(String name, TestTypes.Sub value) {
class MapWithGeneralMapParameters (line 772) | static final class MapWithGeneralMapParameters {
FILE: gson/src/test/java/com/google/gson/functional/MoreSpecificTypeSerializationTest.java
class MoreSpecificTypeSerializationTest (line 36) | @SuppressWarnings("unused")
method setUp (line 40) | @Before
method testSubclassFields (line 45) | @Test
method testListOfSubclassFields (line 53) | @Test
method testMapOfSubclassFields (line 64) | @Test
method testParameterizedSubclassFields (line 78) | @Test
method testListOfParameterizedSubclassFields (line 91) | @Test
method testMapOfParameterizedSubclassFields (line 107) | @Test
class Base (line 121) | private static class Base {
method Base (line 124) | Base(int b) {
class Sub (line 129) | private static class Sub extends Base {
method Sub (line 132) | Sub(int b, int s) {
class ClassWithBaseFields (line 138) | private static class ClassWithBaseFields {
method ClassWithBaseFields (line 141) | ClassWithBaseFields(Base b) {
class ClassWithContainersOfBaseFields (line 146) | private static class ClassWithContainersOfBaseFields {
method ClassWithContainersOfBaseFields (line 150) | ClassWithContainersOfBaseFields(Collection<Base> collection, Map<Str...
class ParameterizedBase (line 156) | private static class ParameterizedBase<T> {
method ParameterizedBase (line 159) | ParameterizedBase(T t) {
class ParameterizedSub (line 164) | private static class ParameterizedSub<T> extends ParameterizedBase<T> {
method ParameterizedSub (line 167) | ParameterizedSub(T t, T s) {
class ClassWithParameterizedBaseFields (line 173) | private static class ClassWithParameterizedBaseFields {
method ClassWithParameterizedBaseFields (line 176) | ClassWithParameterizedBaseFields(ParameterizedBase<String> b) {
class ClassWithContainersOfParameterizedBaseFields (line 181) | private static class ClassWithContainersOfParameterizedBaseFields {
method ClassWithContainersOfParameterizedBaseFields (line 185) | ClassWithContainersOfParameterizedBaseFields(
FILE: gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java
class NamingPolicyTest (line 40) | public class NamingPolicyTest {
method setUp (line 43) | @Before
method testGsonWithNonDefaultFieldNamingPolicySerialization (line 48) | @Test
method testGsonWithNonDefaultFieldNamingPolicyDeserialiation (line 59) | @Test
method testGsonWithLowerCaseDashPolicySerialization (line 67) | @Test
method testGsonWithLowerCaseDotPolicySerialization (line 78) | @Test
method testGsonWithLowerCaseDotPolicyDeserialiation (line 89) | @Test
method testGsonWithLowerCaseDashPolicyDeserialiation (line 97) | @Test
method testGsonWithLowerCaseUnderscorePolicySerialization (line 105) | @Test
method testGsonWithLowerCaseUnderscorePolicyDeserialiation (line 117) | @Test
method testGsonWithSerializedNameFieldNamingPolicySerialization (line 126) | @Test
method testGsonWithSerializedNameFieldNamingPolicyDeserialization (line 134) | @Test
method testGsonDuplicateNameUsingSerializedNameFieldNamingPolicySerialization (line 143) | @Test
method testGsonDuplicateNameDueToBadNamingPolicy (line 158) | @Test
method testGsonWithUpperCamelCaseSpacesPolicySerialiation (line 174) | @Test
method testGsonWithUpperCamelCaseSpacesPolicyDeserialiation (line 186) | @Test
method testGsonWithUpperCaseUnderscorePolicySerialization (line 195) | @Test
method testGsonWithUpperCaseUnderscorePolicyDeserialiation (line 207) | @Test
method testDeprecatedNamingStrategy (line 216) | @Test
method testComplexFieldNameStrategy (line 224) | @Test
method testAtSignInSerializedName (line 236) | @Test
method testGsonWithNameDeserialiation (line 241) | @Test
method testGsonWithAlternateNamesDeserialiation (line 264) | @Test
method testGsonWithAlternateNamesSerialization (line 287) | @Test
class AtName (line 313) | static final class AtName {
class UpperCaseNamingStrategy (line 318) | private static final class UpperCaseNamingStrategy implements FieldNam...
method translateName (line 319) | @Override
class ClassWithDuplicateFields (line 325) | @SuppressWarnings("unused")
method ClassWithDuplicateFields (line 332) | ClassWithDuplicateFields(Integer a) {
method ClassWithDuplicateFields (line 336) | ClassWithDuplicateFields(Double b) {
method ClassWithDuplicateFields (line 340) | ClassWithDuplicateFields(Integer a, Double b) {
class ClassWithComplexFieldName (line 346) | private static class ClassWithComplexFieldName {
method ClassWithComplexFieldName (line 350) | ClassWithComplexFieldName(long value) {
class ClassWithTwoFields (line 355) | @SuppressWarnings("unused")
method ClassWithTwoFields (line 360) | ClassWithTwoFields() {}
FILE: gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java
class NullObjectAndFieldTest (line 42) | public class NullObjectAndFieldTest {
method setUp (line 45) | @Before
method testTopLevelNullObjectSerialization (line 50) | @Test
method testTopLevelNullObjectDeserialization (line 60) | @Test
method testExplicitSerializationOfNulls (line 67) | @Test
method testExplicitDeserializationOfNulls (line 76) | @Test
method testExplicitSerializationOfNullArrayMembers (line 83) | @Test
method testNullWrappedPrimitiveMemberSerialization (line 92) | @Test
method testNullWrappedPrimitiveMemberDeserialization (line 101) | @Test
method testExplicitSerializationOfNullCollectionMembers (line 109) | @Test
method testExplicitSerializationOfNullStringMembers (line 117) | @Test
method testCustomSerializationOfNulls (line 125) | @Test
method testPrintPrintingObjectWithNulls (line 135) | @Test
method testPrintPrintingArraysWithNulls (line 147) | @Test
method testAbsentJsonElementsAreSetToNull (line 160) | @Test
class ClassWithInitializedMembers (line 177) | public static class ClassWithInitializedMembers {
method ClassWithInitializedMembers (line 191) | public ClassWithInitializedMembers() {
class ClassWithNullWrappedPrimitive (line 196) | private static class ClassWithNullWrappedPrimitive {
class ClassWithMembers (line 200) | @SuppressWarnings("unused")
class ClassWithObjectsSerializer (line 207) | private static class ClassWithObjectsSerializer implements JsonSeriali...
method serialize (line 208) | @Override
method testExplicitNullSetsFieldToNullDuringDeserialization (line 217) | @Test
method testCustomTypeAdapterPassesNullSerialization (line 225) | @Test
method testCustomTypeAdapterPassesNullDeserialization (line 240) | @Test
class ObjectWithField (line 254) | private static class ObjectWithField {
FILE: gson/src/test/java/com/google/gson/functional/NumberLimitsTest.java
class NumberLimitsTest (line 25) | public class NumberLimitsTest {
method jsonReader (line 28) | private static JsonReader jsonReader(String json) {
method testJsonReader (line 49) | @Test
method testJsonPrimitive (line 80) | @Test
method testToNumberPolicy (line 117) | @Test
method testLazilyParsedNumber (line 147) | @Test
method testBigDecimalAdapter (line 181) | @Test
method testBigIntegerAdapter (line 209) | @Test
FILE: gson/src/test/java/com/google/gson/functional/ObjectTest.java
class ObjectTest (line 65) | public class ObjectTest {
method setUp (line 70) | @Before
method tearDown (line 80) | @After
method testJsonInSingleQuotesDeserialization (line 86) | @Test
method testJsonInMixedQuotesDeserialization (line 95) | @Test
method testBagOfPrimitivesSerialization (line 104) | @Test
method testBagOfPrimitivesDeserialization (line 110) | @Test
method testBagOfPrimitiveWrappersSerialization (line 118) | @Test
method testBagOfPrimitiveWrappersDeserialization (line 124) | @Test
method testClassWithTransientFieldsSerialization (line 132) | @Test
method testClassWithTransientFieldsDeserialization (line 138) | @Test
method testClassWithTransientFieldsDeserializationTransientFieldsPassedInJsonAreIgnored (line 145) | @Test
method testClassWithNoFieldsSerialization (line 152) | @Test
method testClassWithNoFieldsDeserialization (line 157) | @Test
class Subclass (line 165) | private static class Subclass extends Superclass1 {}
class Superclass1 (line 167) | private static class Superclass1 extends Superclass2 {
class Superclass2 (line 172) | private static class Superclass2 {
method testClassWithDuplicateFields (line 177) | @Test
method testNestedSerialization (line 211) | @Test
method testNestedDeserialization (line 220) | @Test
method testNullSerialization (line 230) | @Test
method testEmptyStringDeserialization (line 235) | @Test
method testTruncatedDeserialization (line 241) | @Test
method testNullDeserialization (line 248) | @Test
method testNullFieldsSerialization (line 255) | @Test
method testNullFieldsDeserialization (line 261) | @Test
method testArrayOfObjectsSerialization (line 270) | @Test
method testArrayOfObjectsDeserialization (line 276) | @Test
method testArrayOfArraysSerialization (line 283) | @Test
method testArrayOfArraysDeserialization (line 289) | @Test
method testArrayOfObjectsAsFields (line 296) | @Test
method testNullArraysDeserialization (line 314) | @Test
method testNullObjectFieldsDeserialization (line 322) | @Test
method testEmptyCollectionInAnObjectDeserialization (line 329) | @Test
class ClassWithCollectionField (line 337) | private static class ClassWithCollectionField {
method testPrimitiveArrayInAnObjectDeserialization (line 341) | @Test
method testNullPrimitiveFieldsDeserialization (line 349) | @Test
method testEmptyCollectionInAnObjectSerialization (line 356) | @Test
method testPrivateNoArgConstructorDeserialization (line 362) | @Test
method testAnonymousLocalClassesSerialization (line 369) | @Test
method testAnonymousLocalClassesCustomSerialization (line 382) | @Test
method testAnonymousLocalClassesCustomDeserialization (line 410) | @Test
method testPrimitiveArrayFieldSerialization (line 439) | @Test
method testClassWithObjectFieldSerialization (line 446) | @Test
class ClassWithObjectField (line 454) | private static class ClassWithObjectField {
method testInnerClassSerialization (line 459) | @Test
method testInnerClassDeserialization (line 468) | @Test
class Parent (line 487) | private static class Parent {
class Child (line 491) | @SuppressWarnings("ClassCanBeStatic")
class ArrayOfArrays (line 497) | private static class ArrayOfArrays {
method ArrayOfArrays (line 500) | ArrayOfArrays() {
method getExpectedJson (line 510) | String getExpectedJson() {
class ClassWithPrivateNoArgsConstructor (line 536) | private static class ClassWithPrivateNoArgsConstructor {
method ClassWithPrivateNoArgsConstructor (line 539) | private ClassWithPrivateNoArgsConstructor() {
method testObjectFieldNamesWithoutQuotesDeserialization (line 545) | @Test
method testStringFieldWithNumberValueDeserialization (line 554) | @Test
method testStringFieldWithEmptyValueSerialization (line 570) | @Test
method testStringFieldWithEmptyValueDeserialization (line 581) | @Test
class ClassWithEmptyStringFields (line 590) | private static class ClassWithEmptyStringFields {
method testJsonObjectSerialization (line 596) | @Test
method testSingletonLists (line 605) | @Test
class Department (line 630) | static final class Department {
class Product (line 635) | static final class Product {
method testDateAsMapObjectField (line 641) | @Test
class HasObjectMap (line 650) | static class HasObjectMap {
method testStaticFieldSerialization (line 660) | @Test
method testStaticFieldDeserialization (line 684) | @Test
class ClassWithStaticField (line 718) | @SuppressWarnings({"PrivateConstructorForUtilityClass", "NonFinalStati...
class ClassWithStaticFinalField (line 723) | @SuppressWarnings("PrivateConstructorForUtilityClass")
method testThrowingDefaultConstructor (line 728) | @Test
class ClassWithThrowingConstructor (line 743) | static class ClassWithThrowingConstructor {
method ClassWithThrowingConstructor (line 747) | public ClassWithThrowingConstructor() {
method testDeeplyNested (line 752) | @Test
class RecursiveClass (line 773) | private static class RecursiveClass {
FILE: gson/src/test/java/com/google/gson/functional/ParameterizedTypesTest.java
class ParameterizedTypesTest (line 50) | public class ParameterizedTypesTest {
method setUp (line 53) | @Before
method testParameterizedTypesSerialization (line 58) | @Test
method testParameterizedTypeDeserialization (line 66) | @Test
method testTypesWithMultipleParametersSerialization (line 83) | @Test
method testTypesWithMultipleParametersDeserialization (line 97) | @Test
method testParameterizedTypeWithCustomSerializer (line 112) | @Test
method testParameterizedTypesWithCustomDeserializer (line 130) | @Test
method testParameterizedTypesWithWriterSerialization (line 153) | @Test
method testParameterizedTypeWithReaderDeserialization (line 162) | @Test
method arrayOf (line 179) | @SuppressWarnings("varargs")
method testVariableTypeFieldsAndGenericArraysSerialization (line 185) | @Test
method testVariableTypeFieldsAndGenericArraysDeserialization (line 202) | @Test
method testVariableTypeDeserialization (line 220) | @Test
method testVariableTypeArrayDeserialization (line 231) | @Test
method testParameterizedTypeWithVariableTypeDeserialization (line 244) | @Test
method testParameterizedTypeGenericArraysSerialization (line 259) | @Test
method testParameterizedTypeGenericArraysDeserialization (line 273) | @Test
class ObjectWithTypeVariables (line 294) | private static class ObjectWithTypeVariables<T extends Number> {
method ObjectWithTypeVariables (line 303) | @SuppressWarnings("unused")
method ObjectWithTypeVariables (line 308) | ObjectWithTypeVariables(
method getExpectedJson (line 323) | String getExpectedJson() {
method appendObjectsToBuilder (line 385) | private void appendObjectsToBuilder(StringBuilder sb, Iterable<? ext...
method appendObjectsToBuilder (line 396) | private void appendObjectsToBuilder(StringBuilder sb, List<? extends...
method toString (line 413) | String toString(T obj) {
class MultiParameters (line 418) | private static final class MultiParameters<A, B, C, D, E> {
method MultiParameters (line 426) | @SuppressWarnings("unused")
method MultiParameters (line 429) | MultiParameters(A a, B b, C c, D d, E e) {
method hashCode (line 438) | @Override
method equals (line 450) | @Override
class Quantity (line 468) | private static class Quantity {
class MyQuantity (line 473) | private static class MyQuantity extends Quantity {
type Measurable (line 478) | private interface Measurable<T> {}
type Field (line 480) | private interface Field<T> {}
type Immutable (line 482) | private interface Immutable {}
class Amount (line 484) | public static final class Amount<Q extends Quantity>
method testDeepParameterizedTypeSerialization (line 491) | @Test
method testDeepParameterizedTypeDeserialization (line 499) | @Test
method assertCorrectlyDeserialized (line 509) | private static void assertCorrectlyDeserialized(Object object) {
method testGsonFromJsonTypeToken (line 516) | @Test
FILE: gson/src/test/java/com/google/gson/functional/PrettyPrintingTest.java
class PrettyPrintingTest (line 40) | public class PrettyPrintingTest {
method setUp (line 44) | @Before
method testPrettyPrintList (line 49) | @Test
method testPrettyPrintArrayOfObjects (line 82) | @Test
method testPrettyPrintArrayOfPrimitives (line 112) | @Test
method testPrettyPrintArrayOfPrimitiveArrays (line 119) | @Test
method testPrettyPrintListOfPrimitiveArrays (line 129) | @Test
method testMap (line 140) | @Test
method testEmptyMapField (line 150) | @Test
class ClassWithMap (line 158) | @SuppressWarnings("unused")
method testMultipleArrays (line 164) | @Test
FILE: gson/src/test/java/com/google/gson/functional/PrimitiveCharacterTest.java
class PrimitiveCharacterTest (line 31) | public class PrimitiveCharacterTest {
method setUp (line 34) | @Before
method testPrimitiveCharacterAutoboxedSerialization (line 39) | @Test
method testPrimitiveCharacterAutoboxedDeserialization (line 46) | @Test
FILE: gson/src/test/java/com/google/gson/functional/PrimitiveTest.java
class PrimitiveTest (line 44) | public class PrimitiveTest {
method setUp (line 47) | @Before
method testPrimitiveIntegerAutoboxedSerialization (line 52) | @Test
method testPrimitiveIntegerAutoboxedDeserialization (line 57) | @Test
method testByteSerialization (line 67) | @Test
method testByteDeserialization (line 78) | @Test
method testByteDeserializationLossy (line 89) | @Test
method testShortSerialization (line 106) | @Test
method testShortDeserialization (line 121) | @Test
method testShortDeserializationLossy (line 132) | @Test
method testIntSerialization (line 149) | @Test
method testLongSerialization (line 164) | @Test
method testFloatSerialization (line 176) | @Test
method testDoubleSerialization (line 194) | @Test
method testPrimitiveIntegerAutoboxedInASingleElementArraySerialization (line 209) | @Test
method testReallyLongValuesSerialization (line 217) | @Test
method testReallyLongValuesDeserialization (line 223) | @Test
method testPrimitiveLongAutoboxedSerialization (line 230) | @Test
method testPrimitiveLongAutoboxedDeserialization (line 236) | @Test
method testPrimitiveLongAutoboxedInASingleElementArraySerialization (line 246) | @Test
method testPrimitiveBooleanAutoboxedSerialization (line 254) | @Test
method testBooleanDeserialization (line 260) | @Test
method testPrimitiveBooleanAutoboxedInASingleElementArraySerialization (line 268) | @Test
method testNumberSerialization (line 276) | @Test
method testNumberDeserialization (line 286) | @Test
method testNumberAsStringDeserialization (line 303) | @Test
method testPrimitiveDoubleAutoboxedSerialization (line 309) | @Test
method testPrimitiveDoubleAutoboxedDeserialization (line 315) | @Test
method testPrimitiveDoubleAutoboxedInASingleElementArraySerialization (line 324) | @Test
method testDoubleAsStringRepresentationDeserialization (line 332) | @Test
method testDoubleNoFractAsStringRepresentationDeserialization (line 343) | @Test
method testDoubleArrayDeserialization (line 354) | @Test
method testLargeDoubleDeserialization (line 370) | @Test
method testBigDecimalSerialization (line 381) | @Test
method testBigDecimalDeserialization (line 388) | @Test
method testBigDecimalInASingleElementArraySerialization (line 395) | @Test
method testSmallValueForBigDecimalSerialization (line 407) | @Test
method testSmallValueForBigDecimalDeserialization (line 414) | @Test
method testBigDecimalPreservePrecisionSerialization (line 421) | @Test
method testBigDecimalPreservePrecisionDeserialization (line 430) | @Test
method testBigDecimalAsStringRepresentationDeserialization (line 439) | @Test
method testBigDecimalNoFractAsStringRepresentationDeserialization (line 447) | @Test
method testBigIntegerSerialization (line 455) | @Test
method testBigIntegerDeserialization (line 461) | @Test
method testBigIntegerInASingleElementArraySerialization (line 468) | @Test
method testSmallValueForBigIntegerSerialization (line 480) | @Test
method testSmallValueForBigIntegerDeserialization (line 487) | @Test
method testBadValueForBigIntegerDeserialization (line 494) | @Test
method testLazilyParsedNumberSerialization (line 500) | @Test
method testLazilyParsedNumberDeserialization (line 507) | @Test
method testMoreSpecificSerialization (line 514) | @Test
method extractElementFromArray (line 525) | private static String extractElementFromArray(String json) {
method testDoubleNaNSerializationNotSupportedByDefault (line 529) | @Test
method testDoubleNaNSerialization (line 543) | @Test
method testDoubleNaNDeserialization (line 550) | @Test
method testFloatNaNSerializationNotSupportedByDefault (line 556) | @Test
method testFloatNaNSerialization (line 569) | @Test
method testFloatNaNDeserialization (line 576) | @Test
method testBigDecimalNaNDeserializationNotSupported (line 582) | @Test
method testDoubleInfinitySerializationNotSupportedByDefault (line 588) | @Test
method testDoubleInfinitySerialization (line 607) | @Test
method testDoubleInfinityDeserialization (line 614) | @Test
method testFloatInfinitySerializationNotSupportedByDefault (line 620) | @Test
method testFloatInfinitySerialization (line 639) | @Test
method testFloatInfinityDeserialization (line 646) | @Test
method testBigDecimalInfinityDeserializationNotSupported (line 652) | @Test
method testNegativeInfinitySerializationNotSupportedByDefault (line 658) | @Test
method testNegativeInfinitySerialization (line 677) | @Test
method testNegativeInfinityDeserialization (line 684) | @Test
method testNegativeInfinityFloatSerializationNotSupportedByDefault (line 690) | @Test
method testNegativeInfinityFloatSerialization (line 709) | @Test
method testNegativeInfinityFloatDeserialization (line 716) | @Test
method testBigDecimalNegativeInfinityDeserializationNotSupported (line 722) | @Test
method testLongAsStringSerialization (line 728) | @Test
method testLongAsStringDeserialization (line 739) | @Test
method testQuotedStringSerializationAndDeserialization (line 749) | @Test
method testUnquotedStringDeserializationFails (line 759) | @Test
method testHtmlCharacterSerialization (line 767) | @Test
method testDeserializePrimitiveWrapperAsObjectField (line 778) | @Test
class ClassWithIntegerField (line 785) | private static class ClassWithIntegerField {
method testPrimitiveClassLiteral (line 789) | @Test
method testDeserializeJsonObjectAsLongPrimitive (line 796) | @Test
method testDeserializeJsonArrayAsLongWrapper (line 801) | @Test
method testDeserializeJsonArrayAsInt (line 806) | @Test
method testDeserializeJsonObjectAsInteger (line 811) | @Test
method testDeserializeJsonObjectAsShortPrimitive (line 816) | @Test
method testDeserializeJsonArrayAsShortWrapper (line 821) | @Test
method testDeserializeJsonArrayAsDoublePrimitive (line 826) | @Test
method testDeserializeJsonObjectAsDoubleWrapper (line 831) | @Test
method testDeserializeJsonObjectAsFloatPrimitive (line 836) | @Test
method testDeserializeJsonArrayAsFloatWrapper (line 841) | @Test
method testDeserializeJsonObjectAsBytePrimitive (line 846) | @Test
method testDeserializeJsonArrayAsByteWrapper (line 851) | @Test
method testDeserializeJsonObjectAsBooleanPrimitive (line 856) | @Test
method testDeserializeJsonArrayAsBooleanWrapper (line 861) | @Test
method testDeserializeJsonArrayAsBigDecimal (line 866) | @Test
method testDeserializeJsonObjectAsBigDecimal (line 871) | @Test
method testDeserializeJsonArrayAsBigInteger (line 876) | @Test
method testDeserializeJsonObjectAsBig
Condensed preview — 305 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,265K chars).
[
{
"path": ".git-blame-ignore-revs",
"chars": 184,
"preview": "# Ignore commit which reformatted code\n2c94c757a6a9426cc2fe47bc1c63f69e7c73b7b4\n\n# Ignore commit which changed line endi"
},
{
"path": ".github/ISSUE_TEMPLATE/bug_report.md",
"chars": 1073,
"preview": "---\nname: Bug report\nabout: Report a Gson bug. Please have a look at the troubleshooting guide (Troubleshooting.md) firs"
},
{
"path": ".github/ISSUE_TEMPLATE/config.yml",
"chars": 297,
"preview": "contact_links:\n - name: Usage question\n url: https://stackoverflow.com/questions/tagged/gson\n about: Ask usage qu"
},
{
"path": ".github/ISSUE_TEMPLATE/feature_request.md",
"chars": 430,
"preview": "---\nname: Feature request\nabout: Request a feature. ⚠️ Gson is in maintenance mode; large feature requests might be reje"
},
{
"path": ".github/dependabot.yml",
"chars": 654,
"preview": "version: 2\nupdates:\n - package-ecosystem: \"maven\"\n directory: \"/\"\n schedule:\n interval: \"monthly\"\n cooldo"
},
{
"path": ".github/pull_request_template.md",
"chars": 2037,
"preview": "<!--\r\n Thank you for your contribution!\r\n Please see the contributing guide: https://github.com/google/.github/blo"
},
{
"path": ".github/workflows/build.yml",
"chars": 5372,
"preview": "name: Build\n\non:\n push:\n branches-ignore:\n # Ignore Dependabot branches because it will also open a pull reques"
},
{
"path": ".github/workflows/check-android-compatibility.yml",
"chars": 1343,
"preview": "# For security reasons this is a separate GitHub workflow, see https://github.com/google/gson/issues/2429#issuecomment-1"
},
{
"path": ".github/workflows/check-api-compatibility.yml",
"chars": 2810,
"preview": "# This workflow makes sure that a pull request does not make any incompatible changes\n# to the public API of Gson\nname: "
},
{
"path": ".github/workflows/cifuzz.yml",
"chars": 1384,
"preview": "name: CIFuzz\non: [pull_request]\npermissions: {}\n\njobs:\n Fuzzing:\n runs-on: ubuntu-latest\n permissions:\n secu"
},
{
"path": ".github/workflows/codeql-analysis.yml",
"chars": 2090,
"preview": "# Based on default config generated by GitHub, see also https://github.com/github/codeql-action\n\nname: \"CodeQL\"\n\non:\n p"
},
{
"path": ".github/workflows/scorecard.yml",
"chars": 3476,
"preview": "# This workflow uses actions that are not certified by GitHub. They are provided\n# by a third-party and are governed by "
},
{
"path": ".gitignore",
"chars": 162,
"preview": ".classpath\n.project\n.settings\neclipsebin\ntarget\n*/target\npom.xml.*\nrelease.properties\n\n.idea\n*.iml\n*.ipr\n*.iws\nclasses\n\n"
},
{
"path": ".mvn/jvm.config",
"chars": 654,
"preview": "--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED\r\n--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-"
},
{
"path": "CHANGELOG.md",
"chars": 23595,
"preview": "Change Log\n==========\n\nThe change log for versions newer than 2.10 is available only on the [GitHub Releases page](https"
},
{
"path": "GsonDesignDocument.md",
"chars": 6912,
"preview": "# Gson Design Document\n\nThis document presents issues that we faced while designing Gson. It is meant for advanced users"
},
{
"path": "LICENSE",
"chars": 11358,
"preview": "\n Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 7269,
"preview": "# Gson\n\nGson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be u"
},
{
"path": "ReleaseProcess.md",
"chars": 6458,
"preview": "# Gson Release Process\n\nThe following is a step-by-step procedure for releasing a new version of Google-Gson.\n\n1. Go thr"
},
{
"path": "Troubleshooting.md",
"chars": 34978,
"preview": "# Troubleshooting Guide\n\nThis guide describes how to troubleshoot common issues when using Gson.\n\n<!-- The '<a id=\"...\">"
},
{
"path": "UserGuide.md",
"chars": 34815,
"preview": "# Gson User Guide\n\n1. [Overview](#overview)\n2. [Goals for Gson](#goals-for-gson)\n3. [Gson Performance and Scalability](#"
},
{
"path": "extras/README.md",
"chars": 203,
"preview": "# extras\n\nThis Maven module contains the source code for supplementary Gson features which\nare not included by default.\n"
},
{
"path": "extras/pom.xml",
"chars": 2762,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n Copyright 2011 Google LLC\n\n Licensed under the Apache License, Version 2."
},
{
"path": "extras/src/main/java/com/google/gson/extras/examples/rawcollections/RawCollectionsExample.java",
"chars": 1954,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "extras/src/main/java/com/google/gson/interceptors/Intercept.java",
"chars": 2084,
"preview": "/*\n * Copyright (C) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "extras/src/main/java/com/google/gson/interceptors/InterceptorFactory.java",
"chars": 2196,
"preview": "/*\n * Copyright (C) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "extras/src/main/java/com/google/gson/interceptors/JsonPostDeserializer.java",
"chars": 1109,
"preview": "/*\n * Copyright (C) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "extras/src/main/java/com/google/gson/typeadapters/PostConstructAdapterFactory.java",
"chars": 2661,
"preview": "/*\n * Copyright (C) 2016 Gson Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
},
{
"path": "extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java",
"chars": 11000,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java",
"chars": 10046,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java",
"chars": 6633,
"preview": "/*\n * Copyright (C) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java",
"chars": 3721,
"preview": "/*\n * Copyright (C) 2016 Gson Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
},
{
"path": "extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java",
"chars": 9139,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java",
"chars": 3409,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/LICENSE",
"chars": 11562,
"preview": "Google Gson\r\n\r\n Apache License\r\n Version 2.0, January 2004\r\n "
},
{
"path": "gson/README.md",
"chars": 175,
"preview": "# gson\n\nThis Maven module contains the Gson source code. The artifacts created by this module\nare deployed to Maven Cent"
},
{
"path": "gson/pom.xml",
"chars": 22777,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n Copyright 2008 Google LLC\n\n Licensed under the Apache License, Version 2."
},
{
"path": "gson/src/main/java/com/google/gson/ExclusionStrategy.java",
"chars": 4042,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/FieldAttributes.java",
"chars": 4048,
"preview": "/*\n * Copyright (C) 2009 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/FieldNamingPolicy.java",
"chars": 7125,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/FieldNamingStrategy.java",
"chars": 1730,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/FormattingStyle.java",
"chars": 5105,
"preview": "/*\n * Copyright (C) 2022 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/Gson.java",
"chars": 58251,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/GsonBuilder.java",
"chars": 48210,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/InstanceCreator.java",
"chars": 3726,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonArray.java",
"chars": 14918,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonDeserializationContext.java",
"chars": 1709,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonDeserializer.java",
"chars": 3846,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonElement.java",
"chars": 16146,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonIOException.java",
"chars": 1419,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonNull.java",
"chars": 1640,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonObject.java",
"chars": 8903,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonParseException.java",
"chars": 2384,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonParser.java",
"chars": 6572,
"preview": "/*\n * Copyright (C) 2009 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonPrimitive.java",
"chars": 10367,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonSerializationContext.java",
"chars": 1860,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonSerializer.java",
"chars": 3508,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonStreamParser.java",
"chars": 3878,
"preview": "/*\n * Copyright (C) 2009 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/JsonSyntaxException.java",
"chars": 1379,
"preview": "/*\n * Copyright (C) 2010 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/LongSerializationPolicy.java",
"chars": 2457,
"preview": "/*\n * Copyright (C) 2009 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/ReflectionAccessFilter.java",
"chars": 9587,
"preview": "/*\n * Copyright (C) 2022 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/Strictness.java",
"chars": 1031,
"preview": "package com.google.gson;\n\nimport com.google.gson.stream.JsonReader;\nimport com.google.gson.stream.JsonWriter;\n\n/**\n * Mo"
},
{
"path": "gson/src/main/java/com/google/gson/ToNumberPolicy.java",
"chars": 3984,
"preview": "/*\n * Copyright (C) 2021 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/ToNumberStrategy.java",
"chars": 3080,
"preview": "/*\n * Copyright (C) 2021 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/TypeAdapter.java",
"chars": 11920,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/TypeAdapterFactory.java",
"chars": 6426,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/annotations/Expose.java",
"chars": 3504,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/annotations/JsonAdapter.java",
"chars": 5157,
"preview": "/*\n * Copyright (C) 2014 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/annotations/SerializedName.java",
"chars": 3314,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/annotations/Since.java",
"chars": 2442,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/annotations/Until.java",
"chars": 2771,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/annotations/package-info.java",
"chars": 825,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/ConstructorConstructor.java",
"chars": 18147,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/Excluder.java",
"chars": 8380,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/GsonTypes.java",
"chars": 24588,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/JavaVersion.java",
"chars": 2956,
"preview": "/*\n * Copyright (C) 2017 The Gson authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "gson/src/main/java/com/google/gson/internal/JsonReaderInternalAccess.java",
"chars": 1314,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java",
"chars": 2874,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java",
"chars": 19755,
"preview": "/*\n * Copyright (C) 2010 The Android Open Source Project\n * Copyright (C) 2012 Google Inc.\n *\n * Licensed under the Apac"
},
{
"path": "gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java",
"chars": 3259,
"preview": "/*\n * Copyright (C) 2018 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/NumberLimits.java",
"chars": 1129,
"preview": "package com.google.gson.internal;\n\nimport java.math.BigDecimal;\nimport java.math.BigInteger;\n\n/**\n * This class enforces"
},
{
"path": "gson/src/main/java/com/google/gson/internal/ObjectConstructor.java",
"chars": 1004,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/PreJava9DateFormatProvider.java",
"chars": 2160,
"preview": "/*\n * Copyright (C) 2017 The Gson authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "gson/src/main/java/com/google/gson/internal/Primitives.java",
"chars": 3516,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java",
"chars": 4335,
"preview": "/*\n * Copyright (C) 2022 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/Streams.java",
"chars": 5299,
"preview": "/*\n * Copyright (C) 2010 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/TroubleshootingGuide.java",
"chars": 315,
"preview": "package com.google.gson.internal;\n\npublic class TroubleshootingGuide {\n private TroubleshootingGuide() {}\n\n /** Create"
},
{
"path": "gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java",
"chars": 4520,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/ArrayTypeAdapter.java",
"chars": 3650,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/CollectionTypeAdapterFactory.java",
"chars": 3693,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java",
"chars": 7334,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/EnumTypeAdapter.java",
"chars": 4832,
"preview": "/*\n * Copyright (C) 2024 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/IgnoreJRERequirement.java",
"chars": 399,
"preview": "package com.google.gson.internal.bind;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\n"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/JavaTimeTypeAdapters.java",
"chars": 16409,
"preview": "package com.google.gson.internal.bind;\n\nimport static java.lang.Math.toIntExact;\n\nimport com.google.gson.Gson;\nimport co"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java",
"chars": 8427,
"preview": "/*\n * Copyright (C) 2014 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/JsonElementTypeAdapter.java",
"chars": 5069,
"preview": "/*\n * Copyright (C) 2024 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java",
"chars": 11825,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java",
"chars": 6966,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java",
"chars": 9675,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/NumberTypeAdapter.java",
"chars": 2768,
"preview": "/*\n * Copyright (C) 2020 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java",
"chars": 5418,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java",
"chars": 25992,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/SerializationDelegatingTypeAdapter.java",
"chars": 1090,
"preview": "/*\n * Copyright (C) 2022 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java",
"chars": 7485,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java",
"chars": 3913,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/TypeAdapters.java",
"chars": 36083,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/bind/util/ISO8601Utils.java",
"chars": 13827,
"preview": "/*\n * Copyright (C) 2015 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/package-info.java",
"chars": 927,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/reflect/ReflectionHelper.java",
"chars": 12479,
"preview": "/*\n * Copyright (C) 2021 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/sql/SqlDateTypeAdapter.java",
"chars": 3053,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/sql/SqlTimeTypeAdapter.java",
"chars": 3007,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/sql/SqlTimestampTypeAdapter.java",
"chars": 2091,
"preview": "/*\n * Copyright (C) 2020 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/internal/sql/SqlTypesSupport.java",
"chars": 3428,
"preview": "/*\n * Copyright (C) 2020 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/package-info.java",
"chars": 1092,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/reflect/TypeToken.java",
"chars": 16691,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/reflect/package-info.java",
"chars": 821,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/stream/JsonReader.java",
"chars": 61736,
"preview": "/*\n * Copyright (C) 2010 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/stream/JsonScope.java",
"chars": 1719,
"preview": "/*\n * Copyright (C) 2010 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/stream/JsonToken.java",
"chars": 2033,
"preview": "/*\n * Copyright (C) 2010 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/stream/JsonWriter.java",
"chars": 27050,
"preview": "/*\n * Copyright (C) 2010 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/stream/MalformedJsonException.java",
"chars": 1245,
"preview": "/*\n * Copyright (C) 2010 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/com/google/gson/stream/package-info.java",
"chars": 768,
"preview": "/*\n * Copyright (C) 2021 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java/module-info.java",
"chars": 1118,
"preview": "/*\n * Copyright (C) 2018 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/main/java-templates/com/google/gson/internal/GsonBuildConfig.java",
"chars": 1139,
"preview": "/*\n * Copyright (C) 2018 The Gson authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "gson/src/main/resources/META-INF/proguard/gson.pro",
"chars": 3180,
"preview": "### Gson ProGuard and R8 rules which are relevant for all users\n### This file is automatically recognized by ProGuard an"
},
{
"path": "gson/src/test/java/com/google/gson/CommentsTest.java",
"chars": 1411,
"preview": "/*\n * Copyright (C) 2010 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/DefaultInetAddressTypeAdapterTest.java",
"chars": 1475,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/DefaultMapJsonSerializerTest.java",
"chars": 2301,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/ExposeAnnotationExclusionStrategyTest.java",
"chars": 3178,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/FieldAttributesTest.java",
"chars": 2541,
"preview": "/*\n * Copyright (C) 2009 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/FieldNamingPolicyTest.java",
"chars": 4587,
"preview": "/*\n * Copyright (C) 2021 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/GenericArrayTypeTest.java",
"chars": 2017,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/GsonBuilderTest.java",
"chars": 15234,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/GsonTest.java",
"chars": 23216,
"preview": "/*\n * Copyright (C) 2016 The Gson Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "gson/src/test/java/com/google/gson/GsonTypeAdapterTest.java",
"chars": 6036,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/InnerClassExclusionStrategyTest.java",
"chars": 2492,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/JavaSerializationTest.java",
"chars": 2910,
"preview": "/*\n * Copyright (C) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/JsonArrayAsListSuiteTest.java",
"chars": 2533,
"preview": "package com.google.gson;\n\nimport com.google.common.collect.testing.ListTestSuiteBuilder;\nimport com.google.common.collec"
},
{
"path": "gson/src/test/java/com/google/gson/JsonArrayAsListTest.java",
"chars": 10180,
"preview": "/*\n * Copyright (C) 2022 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/JsonArrayTest.java",
"chars": 10342,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/JsonNullTest.java",
"chars": 1536,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/JsonObjectAsMapSuiteTest.java",
"chars": 3288,
"preview": "package com.google.gson;\n\nimport com.google.common.collect.testing.MapTestSuiteBuilder;\nimport com.google.common.collect"
},
{
"path": "gson/src/test/java/com/google/gson/JsonObjectAsMapTest.java",
"chars": 9291,
"preview": "/*\n * Copyright (C) 2022 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/JsonObjectTest.java",
"chars": 11662,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/JsonParserParameterizedTest.java",
"chars": 1815,
"preview": "/*\n * Copyright (C) 2022 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/JsonParserTest.java",
"chars": 6955,
"preview": "/*\n * Copyright (C) 2009 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/JsonPrimitiveTest.java",
"chars": 12966,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/JsonStreamParserTest.java",
"chars": 3284,
"preview": "/*\n * Copyright (C) 2009 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/LongSerializationPolicyTest.java",
"chars": 3084,
"preview": "/*\n * Copyright (C) 2009 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/MixedStreamTest.java",
"chars": 8615,
"preview": "/*\n * Copyright (C) 2010 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/ObjectTypeAdapterParameterizedTest.java",
"chars": 1796,
"preview": "/*\n * Copyright (C) 2022 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/ObjectTypeAdapterTest.java",
"chars": 3878,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/OverrideCoreTypeAdaptersTest.java",
"chars": 3090,
"preview": "/*\n * Copyright (C) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/ParameterizedTypeFixtures.java",
"chars": 5416,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/ParameterizedTypeTest.java",
"chars": 2003,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/PrimitiveTypeAdapter.java",
"chars": 2214,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/SubsetTest.java",
"chars": 978,
"preview": "package com.google.gson;\n\nimport static com.google.common.truth.Truth.assertThat;\n\nimport java.util.List;\nimport org.jun"
},
{
"path": "gson/src/test/java/com/google/gson/ToNumberPolicyTest.java",
"chars": 7431,
"preview": "/*\n * Copyright (C) 2021 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/TypeAdapterTest.java",
"chars": 4289,
"preview": "/*\n * Copyright (C) 2022 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/VersionExclusionStrategyTest.java",
"chars": 3942,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/common/MoreAsserts.java",
"chars": 3621,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/common/TestTypes.java",
"chars": 11762,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/ArrayTest.java",
"chars": 9792,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/CircularReferenceTest.java",
"chars": 4949,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/CollectionTest.java",
"chars": 17141,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/ConcurrencyTest.java",
"chars": 4726,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/CustomDeserializerTest.java",
"chars": 6620,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/CustomSerializerTest.java",
"chars": 4166,
"preview": "/*\n * Copyright (C) 2009 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/CustomTypeAdaptersTest.java",
"chars": 17858,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/DefaultTypeAdaptersTest.java",
"chars": 40033,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/DelegateTypeAdapterTest.java",
"chars": 3061,
"preview": "/*\n * Copyright (C) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/EnumTest.java",
"chars": 10220,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/EnumWithObfuscatedTest.java",
"chars": 1634,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/EscapingTest.java",
"chars": 3549,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/ExclusionStrategyFunctionalTest.java",
"chars": 7871,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/ExposeFieldsTest.java",
"chars": 5321,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/FieldExclusionTest.java",
"chars": 2693,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/FieldNamingTest.java",
"chars": 4646,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/FormattingStyleTest.java",
"chars": 7533,
"preview": "/*\n * Copyright (C) 2022 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/GsonVersionDiagnosticsTest.java",
"chars": 3224,
"preview": "/*\n * Copyright (C) 2018 Gson Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
},
{
"path": "gson/src/test/java/com/google/gson/functional/InheritanceTest.java",
"chars": 9590,
"preview": "/*\n * Copyright (C) 2009 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/InstanceCreatorTest.java",
"chars": 4122,
"preview": "/*\n * Copyright (C) 2009 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/InterfaceTest.java",
"chars": 1984,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/InternationalizationTest.java",
"chars": 2700,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/Java17RecordTest.java",
"chars": 16655,
"preview": "/*\n * Copyright (C) 2022 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/JavaUtilConcurrentAtomicTest.java",
"chars": 3927,
"preview": "/*\n * Copyright (C) 2015 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/JavaUtilTest.java",
"chars": 1948,
"preview": "/*\n * Copyright (C) 2015 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnClassesTest.java",
"chars": 29056,
"preview": "/*\n * Copyright (C) 2014 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnFieldsTest.java",
"chars": 25383,
"preview": "/*\n * Copyright (C) 2014 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/JsonAdapterSerializerDeserializerTest.java",
"chars": 8586,
"preview": "/*\n * Copyright (C) 2016 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/JsonParserTest.java",
"chars": 4837,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/JsonTreeTest.java",
"chars": 3734,
"preview": "/*\n * Copyright (C) 2009 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/LeniencyTest.java",
"chars": 1525,
"preview": "/*\n * Copyright (C) 2016 The Gson Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you m"
},
{
"path": "gson/src/test/java/com/google/gson/functional/MapAsArrayTypeAdapterTest.java",
"chars": 5414,
"preview": "/*\n * Copyright (C) 2010 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/MapTest.java",
"chars": 27293,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/MoreSpecificTypeSerializationTest.java",
"chars": 5836,
"preview": "/*\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/NamingPolicyTest.java",
"chars": 13224,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/NullObjectAndFieldTest.java",
"chars": 8599,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
},
{
"path": "gson/src/test/java/com/google/gson/functional/NumberLimitsTest.java",
"chars": 9368,
"preview": "package com.google.gson.functional;\n\nimport static com.google.common.truth.Truth.assertThat;\nimport static org.junit.Ass"
},
{
"path": "gson/src/test/java/com/google/gson/functional/ObjectTest.java",
"chars": 26525,
"preview": "/*\n * Copyright (C) 2008 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may no"
}
]
// ... and 105 more files (download for full content)
About this extraction
This page contains the full source code of the google/gson GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 305 files (2.1 MB), approximately 556.8k tokens, and a symbol index with 3814 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.