summaryrefslogtreecommitdiff
path: root/formats/json-tests
AgeCommit message (Collapse)Author
2024-01-24Add kebab-case naming strategy (#2531)Emil Kantis
2023-12-19Implement ClassDiscriminatorMode.ALL, .NONE, and .POLYMORPHIC (#2532)Leonid Startsev
Implement ClassDiscriminatorMode.ALL, .NONE, and .POLYMORPHIC As a part of the solution for #1247
2023-12-18Do not try to coerce input values for properties (#2530)Leonid Startsev
Do not try to coerce input values for properties that do not have default values. Trying so leads to confusing errors about missing values despite a json key actually present in the input. Fixes #2529
2023-12-04Make empty objects and arrays collapsed in pretty print mode (#2506)Leonid Startsev
because it is a widespread convention. Fixes #2502
2023-10-27Fix TaggedDecoder nullable decoding (#2456)Phillip Schichtel
Make the TaggedDecoder.decodeNullableSerializableElement implementation consistent with AbstractDecoder, so it is possible to differentiate nullable and non-nullable serializers. Fixes #2455
2023-10-26Fix IllegalAccessException (#2469)Leonid Startsev
Being thrown on an attempt to retrieve serializer for some private implementation classes from stdlib. Fixes #2449
2023-10-19Improve polymorphic deserialization optimization: (#2481)Leonid Startsev
Previously, when discriminator was found as the first key in Json, but there was no deserializer for it, we still fell back to a slow path with JsonTree. It was actually meaningless because a slow path always throws exception when a serializer is not found. Such behavior led to unnecessary memory pressure & consumption in exceptional cases (see linked ticket for details). Also make polymorphic deserialization exception messages more meaningful and make them more consistent with serialization ones. Also fix behavior when the actual discriminator value is JsonNull (it should be treated as missing, not as "null" string). Fixes #2478
2023-10-19Add a flag to allow parser to accept trailing commas. (#2480)Leonid Startsev
This is one of the popular community requests and one of the main reasons people ask for Json5 support. Implementing this flag separately will allow for alleviating large paint points quickly without waiting for full Json5 support. Fixes #1812 Relates to: #797, #2221
2023-10-18Build improvements: Kotlin 1.9.20-RC, default target hierarchy, bump Okio ↵Leonid Startsev
(#2473) * Build improvements: Kotlin 1.9.20-RC, default target hierarchy, bump Okio Updated to Kotlin 1.9.20-RC: - Kotlin 1.9.0/10 had some blockers in XCode 15 support. - Simplify WASM setup (it has been changed in 1.9.20). - Drop obsolete Native targets Apply default target hierarchy: - Greatly simplified buildscript for native targets. - Supported targets are now runnable from gutter in the IDE. - Now all possible targets are built by default (without -Pnative.deploy flag), resulting in less confusion for contributors and CI (but longer local `check` times). - Publishing library with K2 should be possible now, no more incorrect `publishNativeKotlinMetadata` failing task. - More targets available in integration-test project. Updated Okio for: - linuxArm64 target support
2023-09-21Get rid of @Suppress("INVISIBLE_REFERENCE") for usage of internal ↵Leonid Startsev
declarations (#2444) * Introduce additional internal opt-in annotation to hide declarations even more * Rename JsonWriter and SerialReader to something more internal-ish * Refactor internal extensions on Json into top-level functions to remove them from completion (because even optable-in declarations are shown in completion for all users) * Propagate opt-ins to verifyKotlinModule task Related: https://youtrack.jetbrains.com/issue/KTIJ-27132
2023-09-14Support decoding maps with boolean keys (#2440)Leonid Startsev
We ignore quoted/unquoted state when decoding maps with number keys, so it is logical to do the same for boolean maps. Fixes #2438
2023-09-12Add support of WASM target to mainline (#2410)igoriakovlev
* Implement wasm target * Slightly fix test data to suite wasm fp parser Wasm fp parser has a different algorithm, so fix the tests to have similar results for all platforms * Update okio version to 3.5.0 * Kotlin 1.9.30+ support
2023-08-11Test & fix several exception messages from Json parserLeonid Startsev
To avoid cryptic and incorrect ones, such as `Expected quotation mark '"', but had '"' instead` or `unexpected token: 10`. Fixes #2360 Fixes #2399 Also remove @PublishedApi from BATCH_SIZE to remove it from public API dump.
2023-08-02Added annotation for named companion objects (#2381)Sergey Shanshin
The annotation will be added to the named companion class by the compiler starting from 1.9.20
2023-07-24Update to Kotlin 1.9.0: (#2364)Leonid Startsev
- Apply @ExperimentalNativeApi on WeakReference usages - Drop Legacy JS compiler as it is deprecated - Update API Dump with .entries enum properties - Update yarn.lock
2023-07-17Use forgotten 'mode' in 'parameterizedTest' (#2367)Leonid Startsev
2023-07-14Fix error triggered by 'consume leading class discriminator' polymorphic ↵Leonid Startsev
parsing optimization: (#2362) In case of an empty object, no exception should be thrown, it should be treated as missing class discriminator. peekString() correctly handles this case. Also fixes misplaced calls in lenient vs non-lenient mode. Fixes #2353
2023-07-05Introduce 'decodeEnumsCaseInsensitive' feature to Json. (#2345)Leonid Startsev
It allows decoding enum values in a case-insensitive manner. It does not affect CLASS kinds or encoding. It is one of the most-voted feature requests. Also enhance JsonNamingStrategy documentation. Fixes #209
2023-06-29Fix beginStructure in JsonTreeDecoder when inner structure descriptor is ↵Ugljesa Jovanovic
same as outer (#2346) Instead of returning the same instance of decoder (with invalid position) a new instance is created, and polyDiscriminator and polyDescriptor are passed to the new instance. This way check for unknown keys in endStructure can properly filter out polymorphic discriminator (by default "type) from potential unknown keys. Fixes #2343
2023-06-23Fix Kotlin user projects build (#2341)Abduqodiri Qurbonzoda
* Remove @SharedImmutable usages The annotation is deprecated and has no effect. * Suppress animal sniffer error in a data class with boolean property The error is a result of changes in data class hashCode generation. The generated code now uses the static Boolean.hashCode() to calculate hash code of boolean properties. The static function is available only since Java 1.8.
2023-06-13Fixed regression with serialization using list parametrized with contextual ↵Sergey Shanshin
types (#2331) Fixes #2323 In the current implementation of serializer lookup caching, if the serializer for the parameter was not found, the `serializerOrNull` function always returned null, without further searching for contextual serializers in the current SerializersModule.
2023-05-17Add support to decode numeric literals containing an exponent (#2227)Roberto Blázquez
Fixes #2078
2023-05-09Implement addAll functions for JsonArrayBuilder (#2156)aSemy
Fixes #2127
2023-04-20Adapt tests for K2 and upcoming deprecations in K1 (#2230)Leonid Startsev
- Move meta-serializable annotations to top-level. - Specify argument for `@Serializable` when companion serializer is used.
2023-04-20Fix value class encoding in various corner cases (#2242)Leonid Startsev
- Value class is located at top-level, but wraps non-primitive and thus does not fall in 'primitive on top-level' branch - Value class is a subclass in a polymorphic hierarchy, but either is primitive or explicitly recorded without type info Note that type info is omitted in the latter case and 'can't add type info to primitive' error is not thrown deliberately, as there seems to be use-cases for that. Fixes #1774 Fixes #2159
2023-04-19Fix incorrect json decoding iterator's .hasNext() behavior on array-wrapped ↵Leonid Startsev
inputs: (#2268) hasNext() shouldn't throw exception if it was called more than once after the stream has ended. Fixes #2267
2023-03-01Add functions for creating JsonPrimitives from unsigned numbers (#2160)aSemy
2023-02-28Fix MissingFieldException duplication (#2213)Vsevolod Tolstopyatov
Fixes #2212
2023-02-24Removed redundant usages of @Serializer annotations (#2200)Sergey Shanshin
If all KSerializer members are overridden in custom serializer, then the annotation '@Serializer' is not needed
2023-02-16Added ability to read buffered huge strings in custom KSerializers (#2012)Alexey Sviridov
Added stream-friendly version of decodeString for new ChunkedDecoder interface. Fixes #1987 Co-authored-by: Leonid Startsev <sandwwraith@users.noreply.github.com>
2023-02-06Added support for null values for nullable enums in lanient mode (#2176)Sergey Shanshin
Fixed #2170 Co-authored-by: Leonid Startsev <sandwwraith@users.noreply.github.com>
2023-02-06Added function to run tests by specified compiler version (#2148)Sergey Shanshin
2023-01-24Provide support for JsonNamingStrategy to be used in Json for properties' ↵Leonid Startsev
names. (#2111) Provide a basic implementation of SnakeCase strategy Fixes #33
2023-01-09Uncomment all stale tests that depended on Kotlin upgrade (#2147)Leonid Startsev
2022-11-29Correctly handle situation where different serializers can be provided (#2113)Leonid Startsev
for the same KClass in SealedClassSerializer. Previous fix supported only equal serializers. Fixes #2110 Fixes #1937
2022-11-24Introduce CharArray pooling for InputStream decoding (#2100)Vsevolod Tolstopyatov
* Add benchmark * Introduce pooling of CharArray for InputStream decoding: by default, 16k buffer is allocated for char-related operations, and it may create a non-trivial GC pressure for small objects decoding * The estimated performance improvement is tens of percents, reaching 70% on our ASCII benchmarks Fixes #1893
2022-11-01Fixed serializers caching for parametrized types from different class loadersSergey Shanshin
Fixes #2065 PR #2070 Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2022-10-27Remove experimentality from serializer(java.lang.Type) function family (#2069)Leonid Startsev
As it is needed for third-part converter libraries. Revamp docs for all overloads of serializer().
2022-10-21Support unquoted literal JSON values (#2041)aSemy
This PR provides a new function for encoding raw JSON content, without quoting it as a string. This allows for encoding JSON numbers of any size or precision, so BigDecimal and BigInteger can be supported. Fixes #1051 Fixes #1405 The implementation is similar to how unsigned numbers are handled. JsonUnquotedLiteral() is a new function that allows creating literal JSON content. Added val coerceToInlineType to JsonLiteral, so that JsonUnquotedLiteral could use encodeInline() Defined val jsonUnquotedLiteralDescriptor as a 'marker', for use with encodeInline() ComposerForUnquotedLiterals (based on ComposerForUnsignedNumbers) will 'override' the encoder when a JsonLiteral has the jsonUnquotedLiteralDescriptor marker, and will encode the content as a string without surrounding quotes.
2022-10-13Update test assertions to use IntelliJ "Click to see difference" format (#2062)aSemy
This makes test failures easier to see, because when the test fails IntelliJ will generate a 'click to see difference' link that opens the IntelliJ comparison editor, with the two strings provided. https://stackoverflow.com/q/10934743/4161471
2022-10-04Add documentation on using typealias for means of global configurationLeonid Startsev
Also add tests on various `@Serializable` applications Apply suggestions from code review Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2022-09-22Added support for the unsigned primitives and arrays as built-inSergey Shanshin
Fixes #1745 Fixes #1480 Resolves #1989
2022-09-22Use EnumSerializer for explicitly serializable enum instead of auto-generatedSergey Shanshin
Resolves #683 #1372
2022-09-15Add functions that can be used by compiler plugin for intrinsics (#2031)Leonid Startsev
2022-09-09Added support of UTF-16 surrogate pairs to okio streamsSergey Shanshin
Fixes #2030
2022-09-07Added test on custom serializer for sealed class with generic parameterSergey.Shanshin
For fix of issues #1705 KT-50764 KT-50718
2022-08-15Fixed decoding of huge JSON data for okio streamsSergey Shanshin
Fixes #2006 Co-authored-by: Leonid Startsev <sandwwraith@users.noreply.github.com>
2022-07-12Improved okio support (#1982)Sergey Shanshin
2022-07-11Make MissingFieldException public (#1983)Vsevolod Tolstopyatov
Fixes #1266
2022-07-07Add @MetaSerializable annotation (#1979)Leonid Startsev
Co-authored-by: rsinukov <rxsinukov@gmail.com> Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>