├── .github └── workflows │ └── maven.yml ├── .gitignore ├── .jenkins └── settings.xml ├── KEYS ├── LICENSE ├── NOTICE ├── getrelease.sh ├── johnzon-core ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── johnzon │ │ │ └── core │ │ │ ├── AbstractJsonFactory.java │ │ │ ├── BufferStrategy.java │ │ │ ├── BufferStrategyFactory.java │ │ │ ├── Buffered.java │ │ │ ├── CommentsJsonStreamParserImpl.java │ │ │ ├── DiffBase.java │ │ │ ├── Experimental.java │ │ │ ├── HStack.java │ │ │ ├── JohnzonJsonParser.java │ │ │ ├── JohnzonJsonParserImpl.java │ │ │ ├── JsonArrayBuilderImpl.java │ │ │ ├── JsonArrayImpl.java │ │ │ ├── JsonBuilderFactoryImpl.java │ │ │ ├── JsonChars.java │ │ │ ├── JsonDoubleImpl.java │ │ │ ├── JsonGeneratorFactoryImpl.java │ │ │ ├── JsonGeneratorImpl.java │ │ │ ├── JsonInMemoryParser.java │ │ │ ├── JsonLocationImpl.java │ │ │ ├── JsonLongImpl.java │ │ │ ├── JsonMergePatchDiff.java │ │ │ ├── JsonMergePatchImpl.java │ │ │ ├── JsonNumberImpl.java │ │ │ ├── JsonObjectBuilderImpl.java │ │ │ ├── JsonObjectImpl.java │ │ │ ├── JsonParserFactoryImpl.java │ │ │ ├── JsonPatchBuilderImpl.java │ │ │ ├── JsonPatchDiff.java │ │ │ ├── JsonPatchImpl.java │ │ │ ├── JsonPointerImpl.java │ │ │ ├── JsonPointerUtil.java │ │ │ ├── JsonProviderImpl.java │ │ │ ├── JsonReaderFactoryImpl.java │ │ │ ├── JsonReaderImpl.java │ │ │ ├── JsonStreamParserImpl.java │ │ │ ├── JsonStringImpl.java │ │ │ ├── JsonWriterFactoryImpl.java │ │ │ ├── JsonWriterImpl.java │ │ │ ├── RFC4627AwareInputStreamReader.java │ │ │ ├── RejectDuplicateKeysMode.java │ │ │ ├── SerializableValue.java │ │ │ ├── SimpleStack.java │ │ │ ├── Snippet.java │ │ │ ├── Strings.java │ │ │ ├── ThreadLocalBufferCache.java │ │ │ ├── Types.java │ │ │ ├── io │ │ │ └── BoundedOutputStreamWriter.java │ │ │ └── util │ │ │ ├── ArrayUtil.java │ │ │ └── ClassUtil.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── jakarta.json.spi.JsonProvider │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── johnzon │ │ └── core │ │ ├── BrokenDefaultTest.java │ │ ├── BufferStrategyFactoryTest.java │ │ ├── HStackTest.java │ │ ├── JsonArrayBuilderImplTest.java │ │ ├── JsonArrayImplTest.java │ │ ├── JsonBuilderFactoryTest.java │ │ ├── JsonCollectorTest.java │ │ ├── JsonGeneratorFactoryImplTest.java │ │ ├── JsonGeneratorImplTest.java │ │ ├── JsonInMemoryParserTest.java │ │ ├── JsonMergeBatchDiffTest.java │ │ ├── JsonMergeBatchTest.java │ │ ├── JsonNumberTest.java │ │ ├── JsonObjectBuilderImplTest.java │ │ ├── JsonObjectImplTest.java │ │ ├── JsonParserStreamingTest.java │ │ ├── JsonParserTest.java │ │ ├── JsonPatchBuilderTest.java │ │ ├── JsonPatchDiffTest.java │ │ ├── JsonPatchTest.java │ │ ├── JsonPointerTest.java │ │ ├── JsonPointerUtilTest.java │ │ ├── JsonProviderTest.java │ │ ├── JsonReaderImplTest.java │ │ ├── JsonStreamParserImplTest.java │ │ ├── JsonWriterImplTest.java │ │ ├── LocationTest.java │ │ ├── OverflowTest.java │ │ ├── SerializationTest.java │ │ ├── SnippetTest.java │ │ ├── StrictJsonPointerFactoryTest.java │ │ ├── TypesTest.java │ │ └── io │ │ └── BoundedOutputStreamWriterTest.java │ └── resources │ ├── bench │ ├── big_600kb.json │ ├── huge_1mb.json │ ├── large_130kb.json │ ├── medium_11kb.json │ ├── small_3kb.json │ ├── tiny_50b.json │ ├── unicode_chars_1400kb.txt │ └── unicode_chars_170kb.txt │ └── json │ ├── array.json │ ├── bigdecimal.json │ ├── comments.json │ ├── empty.json │ ├── emptyarray.json │ ├── escaping.json │ ├── fails │ ├── fail1.json │ ├── fail10.json │ ├── fail11.json │ ├── fail12.json │ ├── fail13.json │ ├── fail14.json │ ├── fail15.json │ ├── fail16.json │ ├── fail17.json │ ├── fail18.json │ ├── fail19.json │ ├── fail2.json │ ├── fail20.json │ ├── fail21.json │ ├── fail22.json │ ├── fail23.json │ ├── fail24.json │ ├── fail25.json │ ├── fail26.json │ ├── fail27.json │ ├── fail28.json │ ├── fail29.json │ ├── fail3.json │ ├── fail30.json │ ├── fail31.json │ ├── fail32.json │ ├── fail33.json │ ├── fail34.json │ ├── fail35.json │ ├── fail36.json │ ├── fail37.json │ ├── fail38.json │ ├── fail39.json │ ├── fail4.json │ ├── fail40.json │ ├── fail41.json │ ├── fail42.json │ ├── fail43.json │ ├── fail44.json │ ├── fail45.json │ ├── fail46.json │ ├── fail47.json │ ├── fail48.json │ ├── fail49.json │ ├── fail5.json │ ├── fail50.json │ ├── fail51.json │ ├── fail52.json │ ├── fail53.json │ ├── fail54.json │ ├── fail55.json │ ├── fail56.json │ ├── fail57.json │ ├── fail58.json │ ├── fail59.json │ ├── fail6.json │ ├── fail60.json │ ├── fail61.json │ ├── fail62.json │ ├── fail63.json │ ├── fail64.json │ ├── fail65.json │ ├── fail66.json │ ├── fail67.json │ ├── fail68.json │ ├── fail69.json │ ├── fail7.json │ ├── fail70.json │ ├── fail71.json │ ├── fail72.json │ ├── fail8.json │ ├── fail9.json │ └── numbers.json │ ├── jsonPointerTest.json │ ├── nested.json │ ├── numbers.json │ ├── simple.json │ ├── simple2.json │ ├── simple_utf16le.json │ ├── special.json │ ├── stringescape.json │ └── unicode.json ├── johnzon-distribution ├── pom.xml └── src │ └── assembly │ ├── bin.xml │ └── src.xml ├── johnzon-jaxrs ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── johnzon │ │ └── jaxrs │ │ ├── ConfigurableJohnzonProvider.java │ │ ├── DelegateProvider.java │ │ ├── IgnorableTypes.java │ │ ├── JohnzonMessageBodyReader.java │ │ ├── JohnzonMessageBodyWriter.java │ │ ├── JohnzonProvider.java │ │ ├── JsrMessageBodyReader.java │ │ ├── JsrMessageBodyWriter.java │ │ ├── JsrProvider.java │ │ ├── NoContentExceptionHandlerReader.java │ │ ├── WadlDocumentMessageBodyWriter.java │ │ ├── WildcardConfigurableJohnzonProvider.java │ │ ├── WildcardJohnzonProvider.java │ │ ├── WildcardJsrProvider.java │ │ └── xml │ │ └── WadlDocumentToJson.java │ └── test │ └── java │ └── org │ └── apache │ └── johnzon │ └── jaxrs │ ├── ConfigurableJohnzonProviderTest.java │ ├── JohnzonProviderTest.java │ ├── JsrProviderTest.java │ └── xml │ └── WadlDocumentToJsonTest.java ├── johnzon-json-extras ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── johnzon │ │ └── jsonb │ │ └── extras │ │ └── polymorphism │ │ └── Polymorphic.java │ └── test │ └── java │ └── org │ └── apache │ └── johnzon │ └── jsonb │ └── extras │ └── polymorphism │ └── PolymorphicTest.java ├── johnzon-jsonb ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── johnzon │ │ │ ├── jaxrs │ │ │ └── jsonb │ │ │ │ └── jaxrs │ │ │ │ └── JsonbJaxrsProvider.java │ │ │ └── jsonb │ │ │ ├── DefaultPropertyVisibilityStrategy.java │ │ │ ├── JohnzonBuilder.java │ │ │ ├── JohnzonJsonb.java │ │ │ ├── JohnzonProvider.java │ │ │ ├── JsonValueParserAdapter.java │ │ │ ├── JsonbAccessMode.java │ │ │ ├── JsonbMappings.java │ │ │ ├── PropertyNamingStrategyFactory.java │ │ │ ├── adapter │ │ │ └── JsonbEnumAdapter.java │ │ │ ├── api │ │ │ └── experimental │ │ │ │ ├── JsonbExtension.java │ │ │ │ └── PolymorphicConfig.java │ │ │ ├── cdi │ │ │ ├── CDIs.java │ │ │ └── JohnzonCdiExtension.java │ │ │ ├── converter │ │ │ ├── JohnzonJsonbAdapter.java │ │ │ ├── JsonbDateConverter.java │ │ │ ├── JsonbDateConverterBase.java │ │ │ ├── JsonbLocalDateConverter.java │ │ │ ├── JsonbLocalDateTimeConverter.java │ │ │ ├── JsonbLocaleParserConverterBase.java │ │ │ ├── JsonbNumberConverter.java │ │ │ ├── JsonbOffsetDateTimeConverter.java │ │ │ ├── JsonbValueConverter.java │ │ │ └── JsonbZonedDateTimeConverter.java │ │ │ ├── extension │ │ │ ├── JsonValueReader.java │ │ │ └── JsonValueWriter.java │ │ │ ├── factory │ │ │ ├── CdiJohnzonAdapterFactory.java │ │ │ └── SimpleJohnzonAdapterFactory.java │ │ │ ├── order │ │ │ └── PerHierarchyAndLexicographicalOrderFieldComparator.java │ │ │ ├── polymorphism │ │ │ ├── JsonbPolymorphismHandler.java │ │ │ └── JsonbPolymorphismTypeInfo.java │ │ │ ├── reflect │ │ │ ├── GenericArrayTypeImpl.java │ │ │ └── Types.java │ │ │ ├── serializer │ │ │ ├── JohnzonDeserializationContext.java │ │ │ └── JohnzonSerializationContext.java │ │ │ └── spi │ │ │ └── JohnzonAdapterFactory.java │ └── resources │ │ └── META-INF │ │ └── services │ │ ├── jakarta.enterprise.inject.spi.Extension │ │ └── jakarta.json.bind.spi.JsonbProvider │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── johnzon │ │ ├── RecursivePolymorphismTest.java │ │ ├── jaxrs │ │ └── jsonb │ │ │ └── jaxrs │ │ │ └── JsonbJaxrsProviderTest.java │ │ └── jsonb │ │ ├── AdapterTest.java │ │ ├── AnnotationOrderTest.java │ │ ├── AnySupportTest.java │ │ ├── CdiAdapterTest.java │ │ ├── ClassConverterTest.java │ │ ├── ConstructorVisibilityTest.java │ │ ├── CustomParameterizedTypeTest.java │ │ ├── DateFormatTest.java │ │ ├── DefaultMappingTest.java │ │ ├── DefaultPropertyVisibilityStrategyTest.java │ │ ├── DeserializationExceptionMessagesTest.java │ │ ├── DynamicBufferResizingTest.java │ │ ├── EnumConverterTest.java │ │ ├── EnumTest.java │ │ ├── ExceptionAsserts.java │ │ ├── FailOnUnknownPropertiesTest.java │ │ ├── FloatTest.java │ │ ├── GenericAdapterTest.java │ │ ├── GenericsTest.java │ │ ├── HidingPublicFieldTest.java │ │ ├── HierarchySerializationTest.java │ │ ├── IJsonTest.java │ │ ├── InterfaceMappingTest.java │ │ ├── JohnzonConverterInJsonbTest.java │ │ ├── JohnzonIgnoreNestedTest.java │ │ ├── JohnzonJsonbTest.java │ │ ├── JohnzonProviderTest.java │ │ ├── JsonbAdapterExceptionsTest.java │ │ ├── JsonbAdapterTest.java │ │ ├── JsonbBeanConstructorExceptionsTest.java │ │ ├── JsonbBeanGetterUserExceptionsTest.java │ │ ├── JsonbBeanSetterUserExceptionsTest.java │ │ ├── JsonbCreatorExceptionsTest.java │ │ ├── JsonbJsonValueTest.java │ │ ├── JsonbReadTest.java │ │ ├── JsonbRecordTest.java │ │ ├── JsonbSerializerExceptionsTest.java │ │ ├── JsonbTransientTest.java │ │ ├── JsonbTypesTest.java │ │ ├── JsonbVisitilityTest.java │ │ ├── JsonbWriteTest.java │ │ ├── NamingTest.java │ │ ├── NillableTest.java │ │ ├── NumberFormatTest.java │ │ ├── ObjectSerializationTest.java │ │ ├── OrderTest.java │ │ ├── OverrideDefaultAdaptersTest.java │ │ ├── ParserGeneratorMappingTest.java │ │ ├── PolymorphicConfigTest.java │ │ ├── PropertyNamingStrategyFactoryTest.java │ │ ├── SerializerTest.java │ │ ├── SerializersMapTest.java │ │ ├── SerializersObjectWithEmbeddedListTest.java │ │ ├── SerializersRoundTripTest.java │ │ ├── SnippetMaxLengthTest.java │ │ ├── TimezoneTest.java │ │ ├── TransientTest.java │ │ ├── api │ │ └── experimental │ │ │ └── JsonbExtensionTest.java │ │ ├── jaxrs │ │ └── JsonbJaxRsTest.java │ │ ├── model │ │ ├── Holder.java │ │ ├── NillableType.java │ │ ├── nillable │ │ │ ├── NotNillablePropertyModel.java │ │ │ ├── notnillable │ │ │ │ ├── StringHolder.java │ │ │ │ └── package-info.java │ │ │ └── package-info.java │ │ └── packageformat │ │ │ ├── FormatFromClassModel.java │ │ │ ├── FormatFromPackageModel.java │ │ │ ├── FormatOnClassModel.java │ │ │ └── package-info.java │ │ ├── polymorphism │ │ ├── JsonbPolymorphismTest.java │ │ └── JsonbPolymorphismValidationTest.java │ │ ├── serializer │ │ └── DeserializationContextTest.java │ │ ├── tck │ │ └── JohnzonOwbCDIProvider.java │ │ └── test │ │ └── JsonbRule.java │ └── resources │ └── META-INF │ └── services │ └── jakarta.enterprise.inject.spi.CDIProvider ├── johnzon-jsonlogic ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── johnzon │ │ └── jsonlogic │ │ ├── JohnzonJsonLogic.java │ │ └── spi │ │ ├── AsyncOperator.java │ │ └── Operator.java │ └── test │ └── java │ └── org │ └── apache │ └── johnzon │ └── jsonlogic │ └── JohnzonJsonLogicTest.java ├── johnzon-jsonschema ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── johnzon │ │ └── jsonschema │ │ ├── JsonSchemaValidator.java │ │ ├── JsonSchemaValidatorFactory.java │ │ ├── ValidationResult.java │ │ ├── generator │ │ ├── PojoGenerator.java │ │ ├── Schema.java │ │ └── SchemaProcessor.java │ │ ├── regex │ │ ├── JavaRegex.java │ │ ├── JavascriptRegex.java │ │ └── JoniRegex.java │ │ └── spi │ │ ├── ValidationContext.java │ │ ├── ValidationExtension.java │ │ └── builtin │ │ ├── BaseNumberValidation.java │ │ ├── BaseValidation.java │ │ ├── ContainsValidation.java │ │ ├── EnumValidation.java │ │ ├── ExclusiveMaximumValidation.java │ │ ├── ExclusiveMinimumValidation.java │ │ ├── IntegerValidation.java │ │ ├── ItemsValidation.java │ │ ├── MaxItemsValidation.java │ │ ├── MaxLengthValidation.java │ │ ├── MaxPropertiesValidation.java │ │ ├── MaximumValidation.java │ │ ├── MinItemsValidation.java │ │ ├── MinLengthValidation.java │ │ ├── MinPropertiesValidation.java │ │ ├── MinimumValidation.java │ │ ├── MultipleOfValidation.java │ │ ├── PatternValidation.java │ │ ├── RequiredValidation.java │ │ ├── TypeValidation.java │ │ └── UniqueItemsValidation.java │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── johnzon │ │ └── jsonschema │ │ ├── JsonSchemaValidatorTest.java │ │ ├── generator │ │ └── PojoGeneratorTest.java │ │ ├── regex │ │ └── JsRegexTest.java │ │ └── spi │ │ └── builtin │ │ └── EnumValidationTest.java │ └── resources │ ├── ConfigMap.json │ └── Node.json ├── johnzon-mapper ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── johnzon │ │ └── mapper │ │ ├── Adapter.java │ │ ├── Cleanable.java │ │ ├── Converter.java │ │ ├── DynamicMappingGenerator.java │ │ ├── ExceptionMessages.java │ │ ├── FactoryCreateException.java │ │ ├── JohnzonAny.java │ │ ├── JohnzonConverter.java │ │ ├── JohnzonCores.java │ │ ├── JohnzonDeduplicateObjects.java │ │ ├── JohnzonIgnore.java │ │ ├── JohnzonIgnoreNested.java │ │ ├── JohnzonProperty.java │ │ ├── JohnzonRecord.java │ │ ├── JohnzonVirtualObject.java │ │ ├── JohnzonVirtualObjects.java │ │ ├── JsonObjectGenerator.java │ │ ├── Mapper.java │ │ ├── MapperBuilder.java │ │ ├── MapperConfig.java │ │ ├── MapperConverter.java │ │ ├── MapperException.java │ │ ├── MappingGenerator.java │ │ ├── MappingGeneratorImpl.java │ │ ├── MappingParser.java │ │ ├── MappingParserImpl.java │ │ ├── Mappings.java │ │ ├── MissingFactoryException.java │ │ ├── ObjectConverter.java │ │ ├── SerializeValueFilter.java │ │ ├── SetterMappingException.java │ │ ├── SnippetFactory.java │ │ ├── TypeAwareAdapter.java │ │ ├── access │ │ ├── AccessMode.java │ │ ├── BaseAccessMode.java │ │ ├── FieldAccessMode.java │ │ ├── FieldAndMethodAccessMode.java │ │ ├── KnownNotOpenedJavaTypesAccessMode.java │ │ ├── Meta.java │ │ └── MethodAccessMode.java │ │ ├── converter │ │ ├── BigDecimalConverter.java │ │ ├── BigIntegerConverter.java │ │ ├── BooleanConverter.java │ │ ├── ByteConverter.java │ │ ├── CachedDelegateConverter.java │ │ ├── CharacterConverter.java │ │ ├── ClassConverter.java │ │ ├── DateConverter.java │ │ ├── DateWithCopyConverter.java │ │ ├── DoubleConverter.java │ │ ├── EnumConverter.java │ │ ├── FloatConverter.java │ │ ├── IntegerConverter.java │ │ ├── LocaleConverter.java │ │ ├── LongConverter.java │ │ ├── ReversedAdapter.java │ │ ├── ShortConverter.java │ │ ├── StringConverter.java │ │ ├── TimestampAdapter.java │ │ ├── URIConverter.java │ │ ├── URLConverter.java │ │ └── UUIDConverter.java │ │ ├── internal │ │ ├── AdapterKey.java │ │ ├── ConverterAdapter.java │ │ ├── DelegatingInputStream.java │ │ ├── DelegatingOutputStream.java │ │ ├── DelegatingReader.java │ │ ├── DelegatingWriter.java │ │ ├── JsonPointerTracker.java │ │ └── Streams.java │ │ ├── jsonp │ │ └── RewindableJsonParser.java │ │ ├── map │ │ └── LazyConverterMap.java │ │ ├── number │ │ └── Validator.java │ │ ├── reflection │ │ ├── Converters.java │ │ ├── Generics.java │ │ ├── JohnzonCollectionType.java │ │ ├── JohnzonListType.java │ │ ├── JohnzonParameterizedType.java │ │ └── Records.java │ │ └── util │ │ ├── ArrayUtil.java │ │ ├── BeanUtil.java │ │ ├── DateUtil.java │ │ └── JsonProviderUtil.java │ └── test │ ├── java │ └── org │ │ ├── apache │ │ └── johnzon │ │ │ ├── core │ │ │ ├── TestBufferProvider.java │ │ │ └── TestJsonGeneratorFactory.java │ │ │ └── mapper │ │ │ ├── AdapterTest.java │ │ │ ├── AdderTest.java │ │ │ ├── AdvancedGenericsTest.java │ │ │ ├── CircularExceptionTest.java │ │ │ ├── CircularObjectsTest.java │ │ │ ├── CustomEnumCodecTest.java │ │ │ ├── DeserializationExceptionMessagesTest.java │ │ │ ├── EnumTest.java │ │ │ ├── ExceptionAsserts.java │ │ │ ├── GenericsTest.java │ │ │ ├── GetterSetterRespectTest.java │ │ │ ├── IndirectAdapterTest.java │ │ │ ├── JPATest.java │ │ │ ├── JohnzonAnyMappingTest.java │ │ │ ├── JohnzonIgnoreNestedTest.java │ │ │ ├── JsonGeneratorCloseTest.java │ │ │ ├── JsonpIntegrationTest.java │ │ │ ├── LiteralTest.java │ │ │ ├── LocaleTest.java │ │ │ ├── MapingsKeyCacheForParameterizedTypesTest.java │ │ │ ├── MapperAdapterExceptionsTest.java │ │ │ ├── MapperBeanConstructorExceptionsTest.java │ │ │ ├── MapperBeanGetterUserExceptionsTest.java │ │ │ ├── MapperBeanSetterUserExceptionsTest.java │ │ │ ├── MapperConfigTest.java │ │ │ ├── MapperConverterExceptionsTest.java │ │ │ ├── MapperEnhancedTest.java │ │ │ ├── MapperGenericsTest.java │ │ │ ├── MapperPerformanceTest.java │ │ │ ├── MapperTest.java │ │ │ ├── MapperVersionTest.java │ │ │ ├── MetaMapperTest.java │ │ │ ├── NoWarningTest.java │ │ │ ├── NullTest.java │ │ │ ├── NumberSerializationTest.java │ │ │ ├── ObjectConverterTest.java │ │ │ ├── ObjectConverterWithAnnotationTest.java │ │ │ ├── ObjectSerializationTest.java │ │ │ ├── ObjectTypeTest.java │ │ │ ├── OverflowTest.java │ │ │ ├── ReadPrimitiveTest.java │ │ │ ├── RecordTest.java │ │ │ ├── SerializeValueFilterTest.java │ │ │ ├── StreamTest.java │ │ │ ├── TypeSimpleNameTest.java │ │ │ ├── access │ │ │ └── FieldAndMethodAccessModeTest.java │ │ │ ├── converter │ │ │ ├── EnumConverterTest.java │ │ │ ├── StringerTest.java │ │ │ ├── TimestampAdapterTest.java │ │ │ └── UUIDConverterTest.java │ │ │ └── internal │ │ │ ├── BeanUtilTest.java │ │ │ └── JsonPointerTrackerTest.java │ │ └── superbiz │ │ ├── ExtendMappingTest.java │ │ ├── Model.java │ │ ├── ModelBase.java │ │ ├── ModelSuperBase.java │ │ ├── ModelSuperSuperBase.java │ │ └── MultiStructureObject.java │ └── resources │ └── JPATest.xml ├── johnzon-maven-plugin ├── .gitattributes ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── johnzon │ │ └── maven │ │ └── plugin │ │ ├── ExampleToModelMojo.java │ │ ├── JsonSchemaToPojoMojo.java │ │ └── PojoToJsonSchemaMojo.java │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── johnzon │ │ └── maven │ │ └── plugin │ │ ├── ExampleToModelMojoTest.java │ │ └── PojoToJsonSchemaMojoTest.java │ └── resources │ ├── SomeValue.java │ └── SomeValue.record.java ├── johnzon-osgi ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── apache │ └── johnzon │ └── osgi │ ├── Activator.java │ ├── Config.java │ ├── cdi │ ├── CdiExtensionFactory.java │ ├── RegisterCdiExtension.java │ └── package-info.java │ └── package-info.java ├── johnzon-websocket ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── johnzon │ │ └── websocket │ │ ├── internal │ │ ├── TypeAwareDecoder.java │ │ ├── jsr │ │ │ ├── FactoryLocator.java │ │ │ ├── JsrDecoder.java │ │ │ ├── JsrEncoder.java │ │ │ └── package-info.java │ │ ├── lazy │ │ │ └── LazySupplier.java │ │ ├── mapper │ │ │ ├── MapperLocator.java │ │ │ ├── MapperLocatorDelegate.java │ │ │ └── package-info.java │ │ └── servlet │ │ │ └── IgnoreIfMissing.java │ │ ├── jsonb │ │ ├── JsonbLocator.java │ │ ├── JsonbLocatorDelegate.java │ │ ├── JsonbTextDecoder.java │ │ └── JsonbTextEncoder.java │ │ ├── jsr │ │ ├── JsrArrayDecoder.java │ │ ├── JsrArrayEncoder.java │ │ ├── JsrObjectDecoder.java │ │ ├── JsrObjectEncoder.java │ │ ├── JsrStructureDecoder.java │ │ ├── JsrStructureEncoder.java │ │ └── package-info.java │ │ └── mapper │ │ ├── JohnzonTextDecoder.java │ │ ├── JohnzonTextEncoder.java │ │ └── package-info.java │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── johnzon │ │ └── websocket │ │ ├── JsrCodecTest.java │ │ ├── MapperCodecTest.java │ │ └── endpoint │ │ ├── ClientEndpointImpl.java │ │ ├── JsrClientEndpointImpl.java │ │ ├── JsrServerEndpointImpl.java │ │ ├── Message.java │ │ ├── ServerEndpointImpl.java │ │ └── ServerReport.java │ └── resources │ └── arquillian.xml ├── pom.xml ├── siteDeploy.sh └── src └── site ├── apt └── privacy-policy.apt ├── markdown ├── download.md ├── index.md └── security.md ├── resources └── images │ └── johnzon_logo.png └── site.xml /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | name: Maven 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | name: Test with Java ${{ matrix.jdk }} 8 | runs-on: ubuntu-latest 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | jdk: [ '11', '17', '21', '22' ] 13 | dist: [ 'zulu' ] 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | with: 18 | persist-credentials: false 19 | 20 | - name: Set up JDK ${{ matrix.jdk }} 21 | uses: actions/setup-java@v4 22 | with: 23 | java-version: ${{ matrix.jdk }} 24 | distribution: ${{ matrix.dist }} 25 | cache: 'maven' 26 | 27 | - name: Maven Package 28 | env: 29 | MAVEN_OPTS: -Dmaven.artifact.threads=64 30 | run: mvn -V package --no-transfer-progress 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .site-content 2 | .idea 3 | *.iml 4 | *.ipr 5 | *.iws 6 | .classpath 7 | .project 8 | .settings 9 | target 10 | .DS_Store 11 | .checkstyle 12 | *.sig 13 | *.patch 14 | -------------------------------------------------------------------------------- /.jenkins/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Apache Johnzon 2 | Copyright 2014-2019 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | -------------------------------------------------------------------------------- /getrelease.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # small script to download the release binaries to store in the dist area 5 | # 6 | # Usage (for default release repo): 7 | # first param is the release verion, second param is optional and a download repository. 8 | # $> ./getrelease.sh 1.1.0 9 | # or during a VOTE e.g. : 10 | # $> ./getrelease.sh 1.1.0 https://repository.apache.org/content/repositories/orgapachejohnzon-1016/ 11 | 12 | 13 | mkdir -p target/dist/johnzon-$1 14 | cd target/dist/johnzon-$1 15 | 16 | if [[ -z $2 ]]; then 17 | repo_path=https://repository.apache.org/content/groups/public 18 | else 19 | repo_path=$2 20 | fi 21 | 22 | echo "Fetching artifacts from " ${repo_path} 23 | curl -O ${repo_path}/org/apache/johnzon/johnzon/${1}/johnzon-${1}-source-release.zip 24 | curl -O ${repo_path}/org/apache/johnzon/johnzon/${1}/johnzon-${1}-source-release.zip.asc 25 | curl -O ${repo_path}/org/apache/johnzon/johnzon/${1}/johnzon-${1}-source-release.zip.md5 26 | curl -O ${repo_path}/org/apache/johnzon/johnzon/${1}/johnzon-${1}-source-release.zip.sha1 27 | 28 | curl -O ${repo_path}/org/apache/johnzon/apache-johnzon/${1}/apache-johnzon-${1}-bin.zip 29 | curl -O ${repo_path}/org/apache/johnzon/apache-johnzon/${1}/apache-johnzon-${1}-bin.zip.asc 30 | curl -O ${repo_path}/org/apache/johnzon/apache-johnzon/${1}/apache-johnzon-${1}-bin.zip.md5 31 | curl -O ${repo_path}/org/apache/johnzon/apache-johnzon/${1}/apache-johnzon-${1}-bin.zip.sha1 32 | -------------------------------------------------------------------------------- /johnzon-core/src/main/java/org/apache/johnzon/core/BufferStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.core; 20 | 21 | import java.io.Serializable; 22 | 23 | /** 24 | * Plugable way to hold various buffers for reading and writing json 25 | */ 26 | public interface BufferStrategy { 27 | BufferProvider newCharProvider(int size); 28 | 29 | interface BufferProvider extends Serializable { 30 | T newBuffer(); 31 | 32 | void release(T value); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /johnzon-core/src/main/java/org/apache/johnzon/core/Buffered.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.johnzon.core; 18 | 19 | /** 20 | * A Buffered is a source or destination of data that is buffered 21 | * before writing or reading. The bufferSize method allows all participants 22 | * in the underlying stream to align on this buffer size for optimization. 23 | * 24 | * This interface is designed in the spirit of {@code java.io.Flushable} and 25 | * {@code java.io.Closeable} 26 | * 27 | * @since 1.2.17 28 | */ 29 | public interface Buffered { // https://github.com/apache/johnzon/pull/84#discussion_r860563179 for the naming ;) 30 | 31 | /** 32 | * The buffer size used by this stream while reading input or before writing 33 | * output to the underlying stream. 34 | * @return the size of the buffer 35 | */ 36 | int bufferSize(); 37 | } 38 | -------------------------------------------------------------------------------- /johnzon-core/src/main/java/org/apache/johnzon/core/DiffBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.johnzon.core; 18 | 19 | import jakarta.json.JsonArray; 20 | import jakarta.json.JsonObject; 21 | import jakarta.json.JsonValue; 22 | import java.io.Serializable; 23 | 24 | /** 25 | * Commonly used methods for diffs 26 | */ 27 | class DiffBase implements Serializable { 28 | protected boolean isJsonObject(JsonValue jsonValue) { 29 | return jsonValue instanceof JsonObject; 30 | } 31 | 32 | protected boolean isJsonArray(JsonValue targetValue) { 33 | return targetValue instanceof JsonArray; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /johnzon-core/src/main/java/org/apache/johnzon/core/Experimental.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.core; 20 | 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.Target; 23 | 24 | import static java.lang.annotation.ElementType.TYPE; 25 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 26 | 27 | /** 28 | * Marker for experimental API. 29 | */ 30 | @Target(TYPE) 31 | @Retention(RUNTIME) 32 | public @interface Experimental { 33 | } 34 | -------------------------------------------------------------------------------- /johnzon-core/src/main/java/org/apache/johnzon/core/SimpleStack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.core; 20 | 21 | class SimpleStack { 22 | 23 | private Element head; 24 | 25 | void push(final T element) { 26 | 27 | final Element tmp = new Element(); 28 | tmp.payload = element; 29 | tmp.previous = head; 30 | head = tmp; 31 | 32 | } 33 | 34 | T pop() { 35 | 36 | final T tmp = head.payload; 37 | head = head.previous; 38 | return tmp; 39 | 40 | } 41 | 42 | T peek() { 43 | return head.payload; 44 | } 45 | 46 | boolean isEmpty() { 47 | return head == null; 48 | } 49 | 50 | private static class Element { 51 | 52 | public Element() { 53 | 54 | } 55 | 56 | private Element previous; 57 | private T payload; 58 | 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /johnzon-core/src/main/resources/META-INF/services/jakarta.json.spi.JsonProvider: -------------------------------------------------------------------------------- 1 | org.apache.johnzon.core.JsonProviderImpl 2 | -------------------------------------------------------------------------------- /johnzon-core/src/test/java/org/apache/johnzon/core/JsonBuilderFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.johnzon.core; 18 | 19 | import java.util.Collections; 20 | 21 | import jakarta.json.Json; 22 | import jakarta.json.JsonBuilderFactory; 23 | import jakarta.json.JsonObject; 24 | 25 | import org.junit.Assert; 26 | import org.junit.Test; 27 | 28 | 29 | public class JsonBuilderFactoryTest { 30 | 31 | @Test 32 | public void testCreateBuilderFactory() { 33 | JsonBuilderFactory factory = Json.createBuilderFactory(Collections.emptyMap()); 34 | JsonObject jsonObject = factory.createObjectBuilder(). 35 | add("name", "home"). 36 | add("city", "Vienna") 37 | .build(); 38 | 39 | //JsonObject 40 | Assert.assertEquals("home", jsonObject.getString("name")); 41 | Assert.assertEquals("Vienna", jsonObject.getString("city")); 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/bench/tiny_50b.json: -------------------------------------------------------------------------------- 1 | { 2 | "debug": "false\ttrue", 3 | "number" : 1.4E10 4 | 5 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/array.json: -------------------------------------------------------------------------------- 1 | [ 2 | "a", 3 | 1, 4 | { 5 | "b": "c" 6 | }, 7 | 5 8 | ] -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/bigdecimal.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1.23E3, 3 | "b": 1.23E-3, 4 | "c": 1.23E+3 5 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/comments.json: -------------------------------------------------------------------------------- 1 | /* super header comment 2 | dont put the brace on another line 3 | it is part of the test */{ 4 | "foo": "//bar//but//not//a/comment", 5 | // a comment 6 | // on multiple lines 7 | //even without space at the beginning; 8 | /* a long comment */ 9 | "another": 5, 10 | "//object": { 11 | // another comment 12 | "sub": "fdmcd" 13 | /* 14 | super long comment 15 | */ 16 | } 17 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/empty.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/emptyarray.json: -------------------------------------------------------------------------------- 1 | [ 2 | 3 | ] -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/escaping.json: -------------------------------------------------------------------------------- 1 | [ 2 | "\"", 3 | "\\", 4 | "\/", 5 | "\b", 6 | "\f", 7 | "\n", 8 | "\r", 9 | "\t", 10 | "\u0044" 11 | ] -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail1.json: -------------------------------------------------------------------------------- 1 | {, 2 | "a": "b", 3 | "c": 4, 4 | "d": [ 5 | 1, 6 | 2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail10.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": 4, 4 | "d": [ 5 | 1, 6 | 2 7 | ] 8 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail11.json: -------------------------------------------------------------------------------- 1 | 2 | "a": "b", 3 | "c": 4, 4 | "d": [ 5 | 1, 6 | 2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail12.json: -------------------------------------------------------------------------------- 1 | { q 2 | "a": "b", 3 | "c": 4, 4 | "d": [ 5 | 1, 6 | 2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail13.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": nul, 4 | "d": [ 5 | 1, 6 | 2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail14.json: -------------------------------------------------------------------------------- 1 | { "x": 2 | "a": "b", 3 | "c": 4, 4 | "d"": [ 5 | 1, 6 | 2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail15.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | true, 4 | "a": "b", 5 | "c": { 6 | "d": [ 7 | 1, 8 | 2 9 | ] 10 | } 11 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail16.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": { 4 | d: [ 5 | 1, 6 | 2 7 | ] 8 | } 9 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail17.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": true { 4 | "d": [ 5 | 1, 6 | 2 7 | ] 8 | } 9 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail18.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | true 4 | "a": "b", 5 | "c": { 6 | "d": [ 7 | 1, 8 | 2 9 | ] 10 | } 11 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail19.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "a": "b", 4 | "c": { 5 | "d": [ 6 | 1, 7 | 2 8 | ] 9 | } 10 | ] -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail2.json: -------------------------------------------------------------------------------- 1 | { 2 | "a":: "b", 3 | "c": 4, 4 | "d": [ 5 | 1, 6 | 2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail20.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "a": "b", 4 | "c": { 5 | "d": [ 6 | 01, 7 | 2 8 | ] 9 | } 10 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail21.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "a": "b", 4 | "c": { 5 | "d": [ 6 | 1.24ee-20, 7 | 2 8 | ] 9 | } 10 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail22.json: -------------------------------------------------------------------------------- 1 | garbage in garbage out -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail23.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "\u6565", 3 | "c": "\u123", 4 | "d": [ 5 | 6 | -2, "\u0048" 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail24.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "a", 3 | "c": \u0074\u0072\u0075\u0065 4 | 5 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail25.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "\u6565", 3 | "c": "\up000", 4 | "d": [ 5 | 6 | -2, "\u0044" 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail26.json: -------------------------------------------------------------------------------- 1 | ,{ 2 | "a": "\u6565", 3 | "d": [ 4 | 5 | -2, "\u0044" 6 | ] 7 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail27.json: -------------------------------------------------------------------------------- 1 | "{ 2 | "a": "\u6565", 3 | "d": [ 4 | 5 | -2, "\u0044" 6 | ] 7 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail28.json: -------------------------------------------------------------------------------- 1 | true, { 2 | "a": "\u6565", 3 | "d": [ 4 | 5 | -2, "\u0044" 6 | ] 7 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail29.json: -------------------------------------------------------------------------------- 1 | : { 2 | "a": "\u6565", 3 | "d": [ 4 | 5 | -2, "\u0044" 6 | ] 7 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail3.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": , "b", 3 | "c": 4, 4 | "d": [ 5 | 1, 6 | 2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail30.json: -------------------------------------------------------------------------------- 1 | null{ 2 | "a": "\u6565", 3 | "d": [ 4 | 5 | -2, "\u0044" 6 | ] 7 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail31.json: -------------------------------------------------------------------------------- 1 | "string":{ 2 | "a": "\u6565", 3 | "d": [ 4 | 5 | -2, "\u0044" 6 | ] 7 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail32.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "\u6565", 3 | "d": [ 4 | 5 | -2, 20e-1.2 6 | ] 7 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail33.json: -------------------------------------------------------------------------------- 1 | 14{ 2 | "a": "\u6565", 3 | "d": [ 4 | 5 | -2, "\u0044" 6 | ] 7 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail34.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "\u6565", 3 | "d": [ 4 | 5 | -2, 2.0e-1.2 6 | ] 7 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail35.json: -------------------------------------------------------------------------------- 1 | , { 2 | "a": "\u6565", 3 | "d": [ 4 | 5 | -2, "\u0044" 6 | ] 7 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail36.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": " " 3 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail37.json: -------------------------------------------------------------------------------- 1 | { 2 | "a 3 | ": "x" 4 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail38.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 12.2e- 3 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail39.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 12.2e 3 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail4.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b",, 3 | "c": 4, 4 | "d": [ 5 | 1, 6 | 2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail40.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "v" 3 | } 4 | some garbage -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail41.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "\vbadescape" 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail42.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": -055 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail43.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": -01.55 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail44.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": -00001.55 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail45.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": " before this word the is a u+0001 char" 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail46.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "before this is a u+00031 char" 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail47.json: -------------------------------------------------------------------------------- 1 | [1,] -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail48.json: -------------------------------------------------------------------------------- 1 | [1, 2 | 2, 3 | 3, 4 | 4, 5 | 5, 6 | ] -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail49.json: -------------------------------------------------------------------------------- 1 | {"a":1,} -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail5.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": 4, 4 | "d": [ 5 | 1 2, 6 | 2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail50.json: -------------------------------------------------------------------------------- 1 | { 2 | "a":1, 3 | "b":2, 4 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail51.json: -------------------------------------------------------------------------------- 1 | ["\uDFAA (missing high surrogate)"] -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail52.json: -------------------------------------------------------------------------------- 1 | ["\uD888\u3210 (invalid second surrogate)"] -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail53.json: -------------------------------------------------------------------------------- 1 | { 2 | "0": 0, 3 | "0": -0, 4 | "1": 1, 5 | "-1": -1, 6 | "9": 9, 7 | "-9": -9, 8 | "10": 10, 9 | "-10", -10, 10 | "100": 100 11 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail54.json: -------------------------------------------------------------------------------- 1 | { 2 | "0": 0, 3 | "0": -0, 4 | "1": 1, 5 | "-1": -1, 6 | "9": 9, 7 | "-9": -9, 8 | "10": 10, 9 | "-10" -10, 10 | "100": 100, 11 | "-100", -100 12 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail55.json: -------------------------------------------------------------------------------- 1 | { 2 | "0": 0, 3 | "0": -0, 4 | "1": 1, 5 | "-1": -1, 6 | "9": 9, 7 | "-9": -9, 8 | "10": 10, 9 | -10 -10, 10 | "100": 100, 11 | "-100", -100 12 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail56.json: -------------------------------------------------------------------------------- 1 | { 2 | "0": 0, 3 | "0": -0, 4 | "1": 1, 5 | "-1": -1, 6 | "9": 9, 7 | "-9": -9, 8 | "10": 10, 9 | "-10", "-10", 10 | "100": 100 11 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail57.json: -------------------------------------------------------------------------------- 1 | ["a":3] -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail58.json: -------------------------------------------------------------------------------- 1 | { 2 | "0":["a":3] 3 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail59.json: -------------------------------------------------------------------------------- 1 | { -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail6.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": 4, 4 | "d": [ 5 | 1, 6 | 2 7 | ]] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail60.json: -------------------------------------------------------------------------------- 1 | [ {}, [] } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail61.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": - 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail62.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail63.json: -------------------------------------------------------------------------------- 1 | { 2 | "a" 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail64.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1., 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail65.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": .5, 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail66.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1-, 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail67.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1.-, 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail68.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1.9e-1.2, 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail69.json: -------------------------------------------------------------------------------- 1 | { 2 | 12 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail7.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": 4, 4 | "d": [ 5 | 1..56, 6 | 2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail70.json: -------------------------------------------------------------------------------- 1 | { 2 | null null 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail71.json: -------------------------------------------------------------------------------- 1 | { 2 | null 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail72.json: -------------------------------------------------------------------------------- 1 | { 2 | "a","b" 3 | } 4 | -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail8.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": 4, 4 | "d": [ 5 | +1, 6 | 2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/fail9.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": 4, 4 | "d"": [ 5 | 1, 6 | 2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/fails/numbers.json: -------------------------------------------------------------------------------- 1 | { 2 | "0": 0, 3 | "0": -0, 4 | "1": 1, 5 | "-1": -1, 6 | "9": 9, 7 | "-9": -9, 8 | "10": 10, 9 | "-10", -10, 10 | "100": 100, 11 | "-100", -100, 12 | "456": 456, 13 | "-456": -456, 14 | "123.12345": 123.12345, 15 | "-123.12345": -123.12345, 16 | "999999999999999999999999999999": 999999999999999999999999999999, 17 | "-999999999999999999999999999999": -999999999999999999999999999999 18 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/jsonPointerTest.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": [ 3 | "bar", 4 | "baz" 5 | ], 6 | "": 0, 7 | "a/b": 1, 8 | "c%d": 2, 9 | "e^f": 3, 10 | "g|h": 4, 11 | "i\\j": 5, 12 | "k\"l": 6, 13 | " ": 7, 14 | "m~n": 8 15 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/nested.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": { 4 | "d": [ 5 | 1, 6 | 2 7 | ] 8 | } 9 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/numbers.json: -------------------------------------------------------------------------------- 1 | { 2 | "0": 0, 3 | "0": -0, 4 | "1": 1, 5 | "-1": -1, 6 | "9": 9, 7 | "-9": -9, 8 | "10": 10, 9 | "-10": -10, 10 | "100": 100, 11 | "-100": -100, 12 | "456": 456, 13 | "-456": -456, 14 | "123.12345": 123.12345, 15 | "-123.12345": -123.12345, 16 | "999999999999999999999999999999": 999999999999999999999999999999, 17 | "-999999999999999999999999999999": -999999999999999999999999999999 18 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/simple.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": 4, 4 | "d": [ 5 | 1, 6 | -2 7 | ], 8 | "e": { 9 | "x": 1, 10 | "y": 2 11 | } 12 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/simple2.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": 4, 4 | "d": [ 5 | 1, 6 | -2 7 | ] 8 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/simple_utf16le.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b", 3 | "c": 4, 4 | "d": [ 5 | 1, 6 | -2 7 | ], 8 | "e":{ 9 | "x": 1, 10 | "y": 2 11 | } 12 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/special.json: -------------------------------------------------------------------------------- 1 | { 2 | "a{": "b,,", 3 | "c::::": ":4::,[{", 4 | "d": [ 5 | 1, 6 | 2, 7 | null, 8 | false, 9 | true, 10 | 4.2 11 | ], 12 | "w":4.6676123, 13 | "r": 0.001, 14 | "1.4312":110, 15 | "\u0044":null, 16 | "\"":"\"", 17 | "থii:üäöÖ.,;.-<>!§$%&()=?ß´'`*+#": "ন:4::,[{" 18 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/stringescape.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "s\"mit\"" 3 | } -------------------------------------------------------------------------------- /johnzon-core/src/test/resources/json/unicode.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "\u6565", 3 | "z": "", 4 | "c": "\u0000", 5 | "f": "\u0070\u0070\u0070a\u0070+++\u0070", 6 | "d": [ 7 | 8 | -2, "\u0020","" 9 | ] 10 | } -------------------------------------------------------------------------------- /johnzon-jaxrs/src/main/java/org/apache/johnzon/jaxrs/IgnorableTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jaxrs; 20 | 21 | import java.util.Collection; 22 | import java.util.HashSet; 23 | 24 | public class IgnorableTypes { 25 | private final Collection ignores; 26 | 27 | protected IgnorableTypes(final Collection ignores) { 28 | this.ignores = ignores == null ? null : new HashSet(ignores); 29 | } 30 | 31 | public boolean isIgnored(final Class type) { 32 | return ignores != null && ignores.contains(type.getName()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /johnzon-jaxrs/src/main/java/org/apache/johnzon/jaxrs/JohnzonProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jaxrs; 20 | 21 | import org.apache.johnzon.mapper.Mapper; 22 | import org.apache.johnzon.mapper.MapperBuilder; 23 | 24 | import jakarta.ws.rs.Consumes; 25 | import jakarta.ws.rs.Produces; 26 | import jakarta.ws.rs.ext.Provider; 27 | import java.util.Collection; 28 | 29 | @Provider 30 | @Produces("application/json") 31 | @Consumes("application/json") 32 | public class JohnzonProvider extends DelegateProvider { 33 | public JohnzonProvider(final Mapper mapper, final Collection ignores) { 34 | super(new JohnzonMessageBodyReader<>(mapper, ignores), new JohnzonMessageBodyWriter<>(mapper, ignores)); 35 | } 36 | 37 | public JohnzonProvider() { 38 | this(new MapperBuilder().setDoCloseOnStreams(false).build(), null); 39 | } 40 | 41 | protected boolean shouldThrowNoContentExceptionOnEmptyStreams() { 42 | return Boolean.getBoolean("johnzon.jaxrs.johnzon.throwNoContentExceptionOnEmptyStreams"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /johnzon-jaxrs/src/main/java/org/apache/johnzon/jaxrs/WildcardJsrProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jaxrs; 20 | 21 | import jakarta.json.JsonStructure; 22 | import jakarta.ws.rs.Consumes; 23 | import jakarta.ws.rs.Produces; 24 | 25 | // @Provider // don't let it be scanned, it would conflict with JsrProvider 26 | @Produces({ 27 | "*/json", 28 | "*/*+json", "*/x-json", 29 | "*/javascript", "*/x-javascript" 30 | }) 31 | @Consumes({ 32 | "*/json", 33 | "*/*+json", "*/x-json", 34 | "*/javascript", "*/x-javascript" 35 | }) 36 | public class WildcardJsrProvider extends DelegateProvider { 37 | public WildcardJsrProvider() { 38 | super(new JsrMessageBodyReader(), new JsrMessageBodyWriter()); 39 | } 40 | 41 | protected boolean shouldThrowNoContentExceptionOnEmptyStreams() { 42 | return Boolean.getBoolean("johnzon.jaxrs.jsr.wildcard.throwNoContentExceptionOnEmptyStreams"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/JohnzonProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb; 20 | 21 | import jakarta.json.bind.JsonbBuilder; 22 | import jakarta.json.bind.spi.JsonbProvider; 23 | 24 | public class JohnzonProvider extends JsonbProvider { 25 | @Override 26 | public JsonbBuilder create() { 27 | return new JohnzonBuilder(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/api/experimental/JsonbExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.api.experimental; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | import jakarta.json.JsonValue; 24 | import jakarta.json.stream.JsonGenerator; 25 | import jakarta.json.stream.JsonParser; 26 | 27 | public interface JsonbExtension { 28 | // https://github.com/eclipse-ee4j/jsonb-api/issues/111 29 | 30 | T fromJsonValue(JsonValue json, Class type); 31 | 32 | T fromJsonValue(JsonValue json, Type runtimeType); 33 | 34 | JsonValue toJsonValue(Object object); 35 | 36 | JsonValue toJsonValue(Object object, Type runtimeType); 37 | 38 | // https://github.com/eclipse-ee4j/jsonb-api/issues/224 39 | 40 | 41 | 42 | T fromJson(JsonParser json, Class type); 43 | 44 | T fromJson(JsonParser json, Type runtimeType); 45 | 46 | void toJson(Object object, JsonGenerator jsonGenerator); 47 | 48 | void toJson(Object object, Type runtimeType, JsonGenerator jsonGenerator); 49 | } 50 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/converter/JsonbDateConverterBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.converter; 20 | 21 | import jakarta.json.bind.annotation.JsonbDateFormat; 22 | import java.time.format.DateTimeFormatter; 23 | 24 | public abstract class JsonbDateConverterBase extends JsonbLocaleParserConverterBase { 25 | protected final DateTimeFormatter formatter; 26 | 27 | protected JsonbDateConverterBase(final JsonbDateFormat dateFormat) { 28 | final String value = dateFormat.value(); 29 | final String locale = dateFormat.locale(); 30 | final boolean ms = value.equals(JsonbDateFormat.TIME_IN_MILLIS); 31 | formatter = ms ? null : 32 | (!locale.equals(JsonbDateFormat.DEFAULT_LOCALE) ? 33 | DateTimeFormatter.ofPattern(value).withLocale(newLocale(locale)) : DateTimeFormatter.ofPattern(value)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/converter/JsonbLocalDateConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.converter; 20 | 21 | import jakarta.json.bind.annotation.JsonbDateFormat; 22 | import java.time.LocalDate; 23 | import java.util.concurrent.TimeUnit; 24 | 25 | public class JsonbLocalDateConverter extends JsonbDateConverterBase { 26 | public JsonbLocalDateConverter(final JsonbDateFormat dateFormat) { 27 | super(dateFormat); 28 | } 29 | 30 | @Override 31 | public String toString(final LocalDate instance) { 32 | return formatter == null ? Long.toString(TimeUnit.DAYS.toMillis(instance.toEpochDay())) : instance.format(formatter); 33 | } 34 | 35 | @Override 36 | public LocalDate fromString(final String text) { 37 | return formatter == null ? LocalDate.ofEpochDay(TimeUnit.MILLISECONDS.toDays(Long.parseLong(text))) : LocalDate.parse(text, formatter); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/converter/JsonbLocalDateTimeConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.converter; 20 | 21 | import jakarta.json.bind.annotation.JsonbDateFormat; 22 | import java.time.Instant; 23 | import java.time.LocalDateTime; 24 | import java.time.ZoneOffset; 25 | 26 | public class JsonbLocalDateTimeConverter extends JsonbDateConverterBase { 27 | public JsonbLocalDateTimeConverter(final JsonbDateFormat dateFormat) { 28 | super(dateFormat); 29 | } 30 | 31 | @Override 32 | public String toString(final LocalDateTime instance) { 33 | return formatter == null ? Long.toString(instance.toInstant(ZoneOffset.UTC).toEpochMilli()) : instance.format(formatter); 34 | } 35 | 36 | @Override 37 | public LocalDateTime fromString(final String text) { 38 | return formatter == null ? LocalDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(text)), ZoneOffset.UTC) : LocalDateTime.parse(text, formatter); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/converter/JsonbLocaleParserConverterBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | import org.apache.johnzon.mapper.converter.LocaleConverter; 23 | 24 | import java.util.Locale; 25 | 26 | public abstract class JsonbLocaleParserConverterBase implements Converter { 27 | private final LocaleConverter delegate = new LocaleConverter(); 28 | 29 | protected Locale newLocale(final String locale) { 30 | return delegate.to(locale); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/converter/JsonbOffsetDateTimeConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.converter; 20 | 21 | import jakarta.json.bind.annotation.JsonbDateFormat; 22 | import java.time.Instant; 23 | import java.time.OffsetDateTime; 24 | import java.time.ZoneId; 25 | 26 | public class JsonbOffsetDateTimeConverter extends JsonbDateConverterBase { 27 | private static final ZoneId UTC = ZoneId.of("UTC"); 28 | 29 | public JsonbOffsetDateTimeConverter(final JsonbDateFormat dateFormat) { 30 | super(dateFormat); 31 | } 32 | 33 | @Override 34 | public String toString(final OffsetDateTime instance) { 35 | return formatter == null ? instance.toString() : instance.format(formatter); 36 | } 37 | 38 | @Override 39 | public OffsetDateTime fromString(final String text) { 40 | return formatter == null ? OffsetDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(text)), UTC) : OffsetDateTime.parse(text, formatter); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/converter/JsonbValueConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | // TODO? 24 | public class JsonbValueConverter implements Converter { 25 | @Override 26 | public String toString(final Object instance) { 27 | return String.valueOf(instance); 28 | } 29 | 30 | @Override 31 | public Object fromString(final String text) { 32 | return text; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/converter/JsonbZonedDateTimeConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.converter; 20 | 21 | import jakarta.json.bind.annotation.JsonbDateFormat; 22 | import java.time.Instant; 23 | import java.time.ZoneId; 24 | import java.time.ZonedDateTime; 25 | 26 | public class JsonbZonedDateTimeConverter extends JsonbDateConverterBase { 27 | private static final ZoneId UTC = ZoneId.of("UTC"); 28 | 29 | public JsonbZonedDateTimeConverter(final JsonbDateFormat dateFormat) { 30 | super(dateFormat); 31 | } 32 | 33 | @Override 34 | public String toString(final ZonedDateTime instance) { 35 | return formatter == null ? Long.toString(instance.toInstant().toEpochMilli()) : instance.format(formatter); 36 | } 37 | 38 | @Override 39 | public ZonedDateTime fromString(final String text) { 40 | return formatter == null ? ZonedDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(text)), UTC) : ZonedDateTime.parse(text, formatter); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/factory/SimpleJohnzonAdapterFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.factory; 20 | 21 | import org.apache.johnzon.jsonb.spi.JohnzonAdapterFactory; 22 | 23 | public class SimpleJohnzonAdapterFactory implements JohnzonAdapterFactory { 24 | @Override 25 | public Instance create(Class type) { 26 | try { 27 | return new ConstantInstance<>(type.newInstance()); 28 | } catch (final InstantiationException | IllegalAccessException e) { 29 | throw new IllegalStateException(e); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/reflect/GenericArrayTypeImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.reflect; 20 | 21 | import java.lang.reflect.GenericArrayType; 22 | import java.lang.reflect.Type; 23 | 24 | public class GenericArrayTypeImpl implements GenericArrayType { 25 | private final Type componentType; 26 | 27 | public GenericArrayTypeImpl(final Type componentType) { 28 | this.componentType = componentType; 29 | } 30 | 31 | @Override 32 | public Type getGenericComponentType() { 33 | return componentType; 34 | } 35 | 36 | @Override 37 | public int hashCode() { 38 | return componentType.hashCode(); 39 | } 40 | 41 | @Override 42 | public boolean equals(final Object obj) { 43 | if (this == obj) { 44 | return true; 45 | } else if (obj instanceof GenericArrayType) { 46 | return ((GenericArrayType) obj).getGenericComponentType().equals(componentType); 47 | } 48 | return false; 49 | 50 | } 51 | 52 | public String toString() { 53 | return componentType + "[]"; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/serializer/JohnzonSerializationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.serializer; 20 | 21 | import org.apache.johnzon.mapper.MappingGenerator; 22 | 23 | import jakarta.json.bind.serializer.SerializationContext; 24 | import jakarta.json.stream.JsonGenerator; 25 | 26 | // TODO: fix it 27 | public class JohnzonSerializationContext implements SerializationContext { 28 | private final MappingGenerator runtime; 29 | 30 | public JohnzonSerializationContext(final MappingGenerator runtime) { 31 | this.runtime = runtime; 32 | } 33 | 34 | @Override 35 | public void serialize(final String key, final T object, final JsonGenerator generator) { 36 | runtime.writeObject(key, object, generator); 37 | } 38 | 39 | @Override 40 | public void serialize(final T object, final JsonGenerator generator) { 41 | runtime.writeObject(object, generator); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/spi/JohnzonAdapterFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.spi; 20 | 21 | import java.io.Serializable; 22 | 23 | public interface JohnzonAdapterFactory { 24 | Instance create(final Class type); 25 | 26 | interface Instance extends Serializable { 27 | T getValue(); 28 | void release(); 29 | } 30 | 31 | class ConstantInstance implements Instance { 32 | private final T value; 33 | 34 | public ConstantInstance(final T value) { 35 | this.value = value; 36 | } 37 | 38 | @Override 39 | public T getValue() { 40 | return value; 41 | } 42 | 43 | @Override 44 | public void release() { 45 | // no-op 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension: -------------------------------------------------------------------------------- 1 | org.apache.johnzon.jsonb.cdi.JohnzonCdiExtension 2 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/main/resources/META-INF/services/jakarta.json.bind.spi.JsonbProvider: -------------------------------------------------------------------------------- 1 | org.apache.johnzon.jsonb.JohnzonProvider 2 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/EnumConverterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb; 20 | 21 | import org.apache.johnzon.jsonb.test.JsonbRule; 22 | import org.junit.Rule; 23 | import org.junit.Test; 24 | 25 | import jakarta.json.bind.annotation.JsonbProperty; 26 | 27 | import static org.junit.Assert.assertEquals; 28 | 29 | public class EnumConverterTest { 30 | @Rule 31 | public final JsonbRule jsonb = new JsonbRule(); 32 | 33 | @Test 34 | public void fromEnumToString() { 35 | assertEquals(AnEnum.B, jsonb.fromJson("{\"value\":\"-2\"}", Wrapper.class).value); 36 | } 37 | 38 | @Test 39 | public void fromStringToEnum() { 40 | final Wrapper wrapper = new Wrapper(); 41 | wrapper.value = AnEnum.A; 42 | assertEquals("{\"value\":\"-1\"}", jsonb.toJson(wrapper)); 43 | } 44 | 45 | public static class Wrapper { 46 | public AnEnum value; 47 | } 48 | 49 | public enum AnEnum { 50 | @JsonbProperty("-1") 51 | A, 52 | 53 | @JsonbProperty("-2") 54 | B 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/EnumTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb; 20 | 21 | import static org.junit.Assert.assertEquals; 22 | 23 | import org.apache.johnzon.jsonb.test.JsonbRule; 24 | import org.junit.Rule; 25 | import org.junit.Test; 26 | 27 | public class EnumTest { 28 | @Rule 29 | public final JsonbRule jsonb = new JsonbRule(); 30 | 31 | @Test 32 | public void noDeclaringClass() { // JOHNZON-292 33 | assertEquals("\"A\"", jsonb.toJson(E.A)); 34 | 35 | final Container c2 = new Container(); 36 | c2.e = E.A; 37 | assertEquals("{\"e\":\"A\"}", jsonb.toJson(c2)); 38 | } 39 | 40 | public static class Container { 41 | public E e; 42 | } 43 | 44 | public enum E { 45 | A {} 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/FloatTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb; 20 | 21 | import static org.junit.Assert.assertEquals; 22 | 23 | import org.apache.johnzon.jsonb.model.Holder; 24 | import org.apache.johnzon.jsonb.test.JsonbRule; 25 | import org.junit.Rule; 26 | import org.junit.Test; 27 | 28 | public class FloatTest { 29 | @Rule 30 | public final JsonbRule jsonb = new JsonbRule(); 31 | 32 | @Test 33 | public void floatMin() { 34 | final String json = jsonb.toJson(new FloatHolder() {{ setInstance(Float.MIN_VALUE); }}); 35 | assertEquals("{\"instance\":" + Float.toString(Float.MIN_VALUE) + "}", json); 36 | } 37 | 38 | public static class FloatHolder implements Holder { 39 | private Float instance; 40 | 41 | @Override 42 | public Float getInstance() { 43 | return instance; 44 | } 45 | 46 | @Override 47 | public void setInstance(final Float instance) { 48 | this.instance = instance; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/HierarchySerializationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb; 20 | 21 | import static org.junit.Assert.assertEquals; 22 | 23 | import org.apache.johnzon.jsonb.test.JsonbRule; 24 | import org.junit.Rule; 25 | import org.junit.Test; 26 | 27 | public class HierarchySerializationTest { 28 | @Rule 29 | public final JsonbRule jsonb = new JsonbRule(); 30 | 31 | @Test 32 | public void parentFieldsAreSerializedBeforeChildOnes() { 33 | assertEquals("{\"parent\":\"parent\",\"child\":\"child\"}", jsonb.toJson(new Child())); 34 | } 35 | 36 | public static class Parent { 37 | public String parent = "parent"; 38 | } 39 | 40 | public static class Child extends Parent { 41 | public String child = "child"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/JohnzonProviderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb; 20 | 21 | import org.junit.Test; 22 | 23 | import jakarta.json.bind.spi.JsonbProvider; 24 | 25 | import static org.junit.Assert.assertNotNull; 26 | 27 | public class JohnzonProviderTest { 28 | @Test 29 | public void provider() { 30 | assertNotNull(JsonbProvider.provider()); 31 | } 32 | 33 | @Test 34 | public void create() { 35 | assertNotNull(JsonbProvider.provider().create()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/TimezoneTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb; 20 | 21 | import static org.junit.Assert.assertEquals; 22 | 23 | import java.util.TimeZone; 24 | 25 | import org.apache.johnzon.jsonb.test.JsonbRule; 26 | import org.junit.Rule; 27 | import org.junit.Test; 28 | 29 | public class TimezoneTest { 30 | @Rule 31 | public final JsonbRule jsonb = new JsonbRule(); 32 | 33 | @Test 34 | public void exceptionOnDeprecated() { 35 | final TimeZoneHolder holder = new TimeZoneHolder(); 36 | holder.instance = TimeZone.getTimeZone("CST"); 37 | jsonb.toJson(holder); 38 | } 39 | 40 | @Test 41 | public void valid() { 42 | final TimeZoneHolder holder = new TimeZoneHolder(); 43 | holder.instance = TimeZone.getTimeZone("UTC"); 44 | assertEquals("{\"instance\":\"UTC\"}", jsonb.toJson(holder)); 45 | } 46 | 47 | public static class TimeZoneHolder { 48 | public TimeZone instance; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/model/Holder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.model; 20 | 21 | public interface Holder { 22 | T getInstance(); 23 | void setInstance(T instance); 24 | } 25 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/model/NillableType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.model; 20 | 21 | import jakarta.json.bind.annotation.JsonbNillable; 22 | 23 | @JsonbNillable 24 | public class NillableType { 25 | public String value; 26 | } 27 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/model/nillable/NotNillablePropertyModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.model.nillable; 20 | 21 | import jakarta.json.bind.annotation.JsonbProperty; 22 | 23 | public class NotNillablePropertyModel { 24 | @JsonbProperty(nillable = false) 25 | public String value; 26 | } 27 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/model/nillable/notnillable/StringHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.model.nillable.notnillable; 20 | 21 | public class StringHolder { 22 | private String string; 23 | 24 | public String getString() { 25 | return string; 26 | } 27 | 28 | public void setString(final String string) { 29 | this.string = string; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/model/nillable/notnillable/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | @JsonbNillable(false) 20 | package org.apache.johnzon.jsonb.model.nillable.notnillable; 21 | 22 | import jakarta.json.bind.annotation.JsonbNillable; 23 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/model/nillable/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | @JsonbNillable 20 | package org.apache.johnzon.jsonb.model.nillable; 21 | 22 | import jakarta.json.bind.annotation.JsonbNillable; 23 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/model/packageformat/FormatFromClassModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.model.packageformat; 20 | 21 | import jakarta.json.bind.annotation.JsonbNumberFormat; 22 | 23 | @JsonbNumberFormat("###,###.###") 24 | public class FormatFromClassModel extends FormatFromPackageModel { 25 | } 26 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/model/packageformat/FormatFromPackageModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.model.packageformat; 20 | 21 | import org.apache.johnzon.jsonb.model.Holder; 22 | 23 | public class FormatFromPackageModel implements Holder { 24 | private Double instance; 25 | 26 | @Override 27 | public Double getInstance() { 28 | return instance; 29 | } 30 | 31 | @Override 32 | public void setInstance(Double instance) { 33 | this.instance = instance; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/model/packageformat/FormatOnClassModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.model.packageformat; 20 | 21 | import java.util.Date; 22 | 23 | import jakarta.json.bind.annotation.JsonbDateFormat; 24 | 25 | import org.apache.johnzon.jsonb.model.Holder; 26 | 27 | @JsonbDateFormat(value = "E DD MMM yyyy HH:mm:ss", locale = "de") 28 | public class FormatOnClassModel implements Holder { 29 | private Date instance; 30 | 31 | @Override 32 | public Date getInstance() { 33 | return instance; 34 | } 35 | 36 | @Override 37 | public void setInstance(final Date instance) { 38 | this.instance = instance; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/model/packageformat/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | @JsonbNumberFormat(value = "###,###.#", locale = "de") 20 | @JsonbDateFormat(value = "E DD MMM yyyy HH:mm:ss z", locale = "it") 21 | package org.apache.johnzon.jsonb.model.packageformat; 22 | 23 | import jakarta.json.bind.annotation.JsonbDateFormat; 24 | import jakarta.json.bind.annotation.JsonbNumberFormat; 25 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/tck/JohnzonOwbCDIProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonb.tck; 20 | 21 | import jakarta.enterprise.inject.spi.CDI; 22 | import org.apache.webbeans.container.OwbCDIProvider; 23 | 24 | // CDI Integration TCKs rely on undefined CDI behaviour: they expect that calling CDI.current() throws an Exception when CDI is not started 25 | // OWB doesn't do that, so we try to achieve this here as a workaround by calling CDI#getBeanManager before returning CDI 26 | public class JohnzonOwbCDIProvider extends OwbCDIProvider { 27 | @Override 28 | public CDI getCDI() { 29 | CDI cdi = super.getCDI(); 30 | cdi.getBeanManager(); 31 | 32 | return cdi; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /johnzon-jsonb/src/test/resources/META-INF/services/jakarta.enterprise.inject.spi.CDIProvider: -------------------------------------------------------------------------------- 1 | org.apache.johnzon.jsonb.tck.JohnzonOwbCDIProvider 2 | -------------------------------------------------------------------------------- /johnzon-jsonlogic/src/main/java/org/apache/johnzon/jsonlogic/spi/Operator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonlogic.spi; 20 | 21 | import org.apache.johnzon.jsonlogic.JohnzonJsonLogic; 22 | 23 | import jakarta.json.JsonValue; 24 | import java.util.concurrent.CompletableFuture; 25 | import java.util.concurrent.CompletionStage; 26 | 27 | import static java.util.concurrent.CompletableFuture.completedFuture; 28 | 29 | @FunctionalInterface 30 | public interface Operator { 31 | default CompletionStage applyStage(JohnzonJsonLogic logic, JsonValue config, JsonValue params) { 32 | try { 33 | return completedFuture(apply(logic, config, params)); 34 | } catch (final RuntimeException re) { 35 | final CompletableFuture promise = new CompletableFuture<>(); 36 | promise.completeExceptionally(re); 37 | return promise; 38 | } 39 | } 40 | 41 | JsonValue apply(JohnzonJsonLogic logic, JsonValue config, JsonValue params); 42 | } 43 | -------------------------------------------------------------------------------- /johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/regex/JavaRegex.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonschema.regex; 20 | 21 | import java.util.function.Predicate; 22 | import java.util.regex.Pattern; 23 | 24 | public class JavaRegex implements Predicate { 25 | 26 | private final Pattern pattern; 27 | 28 | public JavaRegex(final String pattern) { 29 | this.pattern = Pattern.compile(pattern); 30 | } 31 | 32 | @Override 33 | public boolean test(final CharSequence charSequence) { 34 | return pattern.matcher(charSequence).matches(); 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return "JavaRegex{" + pattern + '}'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/spi/ValidationExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonschema.spi; 20 | 21 | import java.util.Optional; 22 | import java.util.function.Function; 23 | import java.util.stream.Stream; 24 | 25 | import jakarta.json.JsonValue; 26 | 27 | import org.apache.johnzon.jsonschema.ValidationResult; 28 | 29 | public interface ValidationExtension { 30 | Optional>> create(ValidationContext model); 31 | } 32 | -------------------------------------------------------------------------------- /johnzon-jsonschema/src/test/java/org/apache/johnzon/jsonschema/regex/JsRegexTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.jsonschema.regex; 20 | 21 | import static org.junit.Assert.assertFalse; 22 | import static org.junit.Assert.assertTrue; 23 | 24 | import java.util.stream.Stream; 25 | 26 | import org.junit.Test; 27 | 28 | public class JsRegexTest { 29 | 30 | @Test 31 | public void valid() { 32 | final String regex = "/^foo/i"; 33 | Stream.of("foo", "foobar", "FoO_") 34 | .forEach(val -> Stream.of(new JavascriptRegex(regex), new JoniRegex(regex)) 35 | .forEach(validator -> assertTrue(validator.toString() + " # " + val, validator.test(val)))); 36 | } 37 | 38 | @Test 39 | public void invalid() { 40 | final String regex = "/^foo/"; 41 | Stream.of("bar", "FoO") 42 | .forEach(val -> Stream.of(new JavascriptRegex(regex), new JoniRegex(regex)) 43 | .forEach(validator -> assertFalse(validator.toString() + " # " + val, validator.test(val)))); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/Cleanable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | public interface Cleanable { 22 | void clean(A value); 23 | } 24 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/Converter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import java.lang.reflect.Type; 22 | 23 | /** 24 | * Convert a given Java Type to it's JSON String representation. 25 | * And the other way around. 26 | * 27 | * An example would be to convert joda LocalDate into Strings and back. 28 | * 29 | * @param the Java type that needs to be converted 30 | */ 31 | public interface Converter extends MapperConverter { 32 | String toString(T instance); 33 | T fromString(String text); 34 | 35 | // for generic converters it allows to explicitly provide the converted type (ex: enum converter) 36 | // typically useful when generic type get resolved to a TypeVariable 37 | interface TypeAccess { 38 | Type type(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/FactoryCreateException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.johnzon.mapper; 18 | 19 | import jakarta.json.JsonObject; 20 | import java.lang.reflect.Type; 21 | 22 | public class FactoryCreateException extends MapperException { 23 | public FactoryCreateException(final Type type, final JsonObject object, final String snippet, final Exception e) { 24 | super(String.format("%s cannot be constructed to deserialize %s: %s%n%s", 25 | ExceptionMessages.simpleName(type), ExceptionMessages.description(object), 26 | snippet, e.getMessage() 27 | ), e); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/JohnzonAny.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.Target; 23 | 24 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 25 | import static java.lang.annotation.ElementType.FIELD; 26 | import static java.lang.annotation.ElementType.METHOD; 27 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 28 | 29 | @Retention(RUNTIME) 30 | @Target({METHOD, ANNOTATION_TYPE, FIELD}) 31 | public @interface JohnzonAny { 32 | } 33 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/JohnzonConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.Target; 23 | 24 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 25 | import static java.lang.annotation.ElementType.FIELD; 26 | import static java.lang.annotation.ElementType.METHOD; 27 | import static java.lang.annotation.ElementType.PARAMETER; 28 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 29 | 30 | @Target({ METHOD, FIELD, PARAMETER, ANNOTATION_TYPE }) 31 | @Retention(RUNTIME) 32 | public @interface JohnzonConverter { 33 | Class value(); 34 | } 35 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/JohnzonDeduplicateObjects.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Mark an Object to leverage object deduplication without having 28 | * to explicitly enable it in the Mapper or JsonB Builder. 29 | * 30 | * The feature only gets activated if this annotation is available 31 | * on the root object to be serialised/deserialised. 32 | * 33 | * @see MapperBuilder#setDeduplicateObjects(Boolean) 34 | */ 35 | @Retention(RetentionPolicy.RUNTIME) 36 | @Target({ElementType.TYPE}) 37 | public @interface JohnzonDeduplicateObjects { 38 | boolean value() default true; 39 | } 40 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/JohnzonIgnore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.Target; 23 | 24 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 25 | import static java.lang.annotation.ElementType.FIELD; 26 | import static java.lang.annotation.ElementType.METHOD; 27 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 28 | 29 | @Target({ METHOD, FIELD, ANNOTATION_TYPE }) 30 | @Retention(RUNTIME) 31 | public @interface JohnzonIgnore { 32 | /** 33 | * Example: @JohnzonIgnore(minVersion = 2) will ignore the value until version is set to 2, 3, ... 34 | * 35 | * @return the first version the decorated field is not ignored. 36 | */ 37 | int minVersion() default -1; 38 | } 39 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/JohnzonIgnoreNested.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.Target; 23 | 24 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 25 | import static java.lang.annotation.ElementType.FIELD; 26 | import static java.lang.annotation.ElementType.METHOD; 27 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 28 | 29 | /** 30 | * Only used during serialization for now. 31 | */ 32 | @Target({ METHOD, FIELD, ANNOTATION_TYPE }) 33 | @Retention(RUNTIME) 34 | public @interface JohnzonIgnoreNested { 35 | /** 36 | * @return the array of properties to avoid in the nested type. 37 | */ 38 | String[] properties() default {}; 39 | } 40 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/JohnzonProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.Target; 23 | 24 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 25 | import static java.lang.annotation.ElementType.FIELD; 26 | import static java.lang.annotation.ElementType.METHOD; 27 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 28 | 29 | @Target({ METHOD, FIELD, ANNOTATION_TYPE }) 30 | @Retention(RUNTIME) 31 | public @interface JohnzonProperty { 32 | /** 33 | * Example: @JohnzonProperty("not_java_name") will consider the decorated property as called "not_java_name" on JSON side. 34 | * 35 | * @return the JSON name for this property. 36 | */ 37 | String value(); 38 | } 39 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/JohnzonRecord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import static java.lang.annotation.ElementType.PARAMETER; 22 | import static java.lang.annotation.ElementType.TYPE; 23 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 24 | 25 | import java.lang.annotation.Retention; 26 | import java.lang.annotation.Target; 27 | 28 | /** 29 | * Forces method named as properties to be used as getters (String foo() will match the attribute foo). 30 | * Also enables a constructor with all properties even if not marked as @ConstructorProperties or equivalent. 31 | * It simulates Java 14+ records. 32 | */ 33 | @Target({ TYPE }) 34 | @Retention(RUNTIME) 35 | public @interface JohnzonRecord { 36 | /** 37 | * When not using -parameters compiler argument, enables to customize parameter names. 38 | * It is only real in @JohnzonRecord classes. 39 | */ 40 | @Target(PARAMETER) 41 | @Retention(RUNTIME) 42 | @interface Name { 43 | String value(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/JohnzonVirtualObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import java.lang.annotation.Inherited; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | import static java.lang.annotation.ElementType.TYPE; 26 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 27 | 28 | /** 29 | * Example: @JohnzonVirtualObject(path = {"nested", "nested-again"}, field = { "a", "b" }) 30 | * will generate {"nested":{"nested-again":{"a":"xxx", "b": "yyy"}}} 31 | */ 32 | @Target(TYPE) 33 | @Retention(RUNTIME) 34 | @Inherited 35 | public @interface JohnzonVirtualObject { 36 | /** 37 | * @return the virtual object(s) path. 38 | */ 39 | String[] path(); 40 | 41 | /** 42 | * @return the list of fields to consider. 43 | */ 44 | Field[] fields(); 45 | 46 | @interface Field { 47 | String value(); 48 | boolean read() default true; 49 | boolean write() default true; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/JohnzonVirtualObjects.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import java.lang.annotation.Inherited; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 26 | import static java.lang.annotation.ElementType.TYPE; 27 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 28 | 29 | @Target({ TYPE, ANNOTATION_TYPE }) 30 | @Retention(RUNTIME) 31 | @Inherited 32 | public @interface JohnzonVirtualObjects { 33 | /** 34 | * @return list of virtual objects for this class. 35 | */ 36 | JohnzonVirtualObject[] value(); 37 | } 38 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MapperConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | 22 | /** 23 | * MapperConverter is the common marker interface for all Converters available in Johnzon 24 | */ 25 | public interface MapperConverter { 26 | } 27 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MapperException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import jakarta.json.JsonException; 22 | 23 | public class MapperException extends JsonException { 24 | public MapperException(final Throwable e) { 25 | super(e.getMessage(), e); 26 | } 27 | 28 | public MapperException(final String s) { 29 | super(s); 30 | } 31 | 32 | public MapperException(final String s, final Throwable cause) { 33 | super(s, cause); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MappingParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import jakarta.json.JsonValue; 22 | import java.lang.reflect.Type; 23 | import java.util.Collection; 24 | 25 | /** 26 | * Handles reading Json for Objects. 27 | */ 28 | public interface MappingParser { 29 | 30 | T readObject(Type targetType); 31 | 32 | T readObject(JsonValue jsonValue, Type targetType); 33 | 34 | default Collection> getSkippedConverters() { 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/SerializeValueFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | public interface SerializeValueFilter { 22 | /** 23 | * @param name the attribute name if set. 24 | * @param value the value which will get serialized. 25 | * @return true if the value should be ignored and not serialized. 26 | */ 27 | boolean shouldIgnore(String name, Object value); 28 | } 29 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/SnippetFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import jakarta.json.JsonValue; 22 | 23 | public interface SnippetFactory { 24 | String of(JsonValue value); 25 | } 26 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/TypeAwareAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import org.apache.johnzon.mapper.internal.AdapterKey; 22 | 23 | import java.lang.reflect.Type; 24 | 25 | public interface TypeAwareAdapter extends Adapter { 26 | Type getTo(); 27 | Type getFrom(); 28 | 29 | default AdapterKey getKey() { 30 | return new AdapterKey(getFrom(), getTo()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/BigDecimalConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | import java.math.BigDecimal; 24 | 25 | public class BigDecimalConverter implements Converter { 26 | @Override 27 | public String toString(final BigDecimal instance) { 28 | return instance.toString(); 29 | } 30 | 31 | @Override 32 | public BigDecimal fromString(final String text) { 33 | return new BigDecimal(text); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/BigIntegerConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | import java.math.BigInteger; 24 | 25 | public class BigIntegerConverter implements Converter { 26 | @Override 27 | public String toString(final BigInteger instance) { 28 | return instance.toString(); 29 | } 30 | 31 | @Override 32 | public BigInteger fromString(final String text) { 33 | return new BigInteger(text); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/BooleanConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | public class BooleanConverter implements Converter { 24 | @Override 25 | public String toString(final Boolean instance) { 26 | return Boolean.toString(instance); 27 | } 28 | 29 | @Override 30 | public Boolean fromString(final String text) { 31 | return Boolean.valueOf(text); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/ByteConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | public class ByteConverter implements Converter { 24 | @Override 25 | public String toString(final Byte instance) { 26 | return Byte.toString(instance); 27 | } 28 | 29 | @Override 30 | public Byte fromString(final String text) { 31 | return Byte.valueOf(text); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/CharacterConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | public class CharacterConverter implements Converter { 24 | @Override 25 | public String toString(final Character instance) { 26 | return Character.toString(instance); 27 | } 28 | 29 | @Override 30 | public Character fromString(final String text) { 31 | return text.length() > 0 ? text.charAt(0) : null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/ClassConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | public class ClassConverter implements Converter> { 24 | @Override 25 | public String toString(final Class instance) { 26 | return instance.getName(); 27 | } 28 | 29 | @Override 30 | public Class fromString(final String text) { 31 | try { 32 | return Class.forName(text, true, Thread.currentThread().getContextClassLoader()); 33 | } catch (final ClassNotFoundException e) { 34 | throw new IllegalArgumentException(e); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/DateWithCopyConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Adapter; 22 | import org.apache.johnzon.mapper.internal.ConverterAdapter; 23 | 24 | import java.util.Date; 25 | 26 | // needed for openjpa for instance which proxies dates 27 | public class DateWithCopyConverter implements Adapter { 28 | private final Adapter delegate; 29 | 30 | public DateWithCopyConverter(final Adapter delegate) { 31 | this.delegate = delegate == null ? new ConverterAdapter<>(DateConverter.ISO_8601_SHORT, Date.class) : delegate; 32 | } 33 | 34 | @Override 35 | public Date to(final String s) { 36 | return delegate.to(s); 37 | } 38 | 39 | @Override 40 | public String from(final Date date) { 41 | return delegate.from(new Date(date.getTime())); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/DoubleConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | public class DoubleConverter implements Converter { 24 | @Override 25 | public String toString(final Double instance) { 26 | return Double.toString(instance); 27 | } 28 | 29 | @Override 30 | public Double fromString(final String text) { 31 | return Double.valueOf(text); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/FloatConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | public class FloatConverter implements Converter { 24 | @Override 25 | public String toString(final Float instance) { 26 | return Float.toString(instance); 27 | } 28 | 29 | @Override 30 | public Float fromString(final String text) { 31 | return Float.valueOf(text); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/IntegerConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | public class IntegerConverter implements Converter { 24 | @Override 25 | public String toString(final Integer instance) { 26 | return Integer.toString(instance); 27 | } 28 | 29 | @Override 30 | public Integer fromString(final String text) { 31 | return Integer.valueOf(text); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/LongConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | public class LongConverter implements Converter { 24 | @Override 25 | public String toString(final Long instance) { 26 | return Long.toString(instance); 27 | } 28 | 29 | @Override 30 | public Long fromString(final String text) { 31 | return Long.valueOf(text); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/ReversedAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Adapter; 22 | 23 | public class ReversedAdapter implements Adapter { 24 | private final Adapter delegate; 25 | 26 | public ReversedAdapter(final Adapter delegate) { 27 | this.delegate = delegate; 28 | } 29 | 30 | @Override 31 | public A to(final B b) { 32 | return delegate.from(b); 33 | } 34 | 35 | @Override 36 | public B from(final A a) { 37 | return delegate.to(a); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/ShortConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | public class ShortConverter implements Converter { 24 | @Override 25 | public String toString(final Short instance) { 26 | return Short.toString(instance); 27 | } 28 | 29 | @Override 30 | public Short fromString(final String text) { 31 | return Short.valueOf(text); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/StringConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | public class StringConverter implements Converter { 24 | @Override 25 | public String toString(final String instance) { 26 | return instance; 27 | } 28 | 29 | @Override 30 | public String fromString(final String text) { 31 | return text; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/TimestampAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Adapter; 22 | 23 | import java.util.Date; 24 | 25 | public class TimestampAdapter implements Adapter { 26 | @Override 27 | public Date to(final Long aLong) { 28 | return aLong == null ? null : new Date(aLong); 29 | } 30 | 31 | @Override 32 | public Long from(final Date date) { 33 | return date == null ? null : date.getTime(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/URIConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | import java.net.URI; 24 | 25 | public class URIConverter implements Converter { 26 | @Override 27 | public String toString(final URI instance) { 28 | return instance.toASCIIString(); 29 | } 30 | 31 | @Override 32 | public URI fromString(final String text) { 33 | return URI.create(text); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/URLConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | import java.net.MalformedURLException; 24 | import java.net.URL; 25 | 26 | public class URLConverter implements Converter { 27 | @Override 28 | public String toString(final URL instance) { 29 | return instance.toExternalForm(); 30 | } 31 | 32 | @Override 33 | public URL fromString(final String text) { 34 | try { 35 | return new URL(text); 36 | } catch (final MalformedURLException e) { 37 | throw new IllegalArgumentException(e); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/converter/UUIDConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Converter; 22 | 23 | import java.util.UUID; 24 | 25 | public class UUIDConverter implements Converter { 26 | @Override 27 | public String toString(UUID instance) { 28 | return instance.toString(); 29 | } 30 | 31 | @Override 32 | public UUID fromString(String text) { 33 | return UUID.fromString(text); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/number/Validator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.number; 20 | 21 | public final class Validator { 22 | private Validator() { 23 | // no-op 24 | } 25 | 26 | public static void validateByte(final int value) { 27 | // bytes have a special handling as they are often used 28 | // to transport binary. So we have to pass on the full 8 bit. 29 | // TODO: ATTENTION: this is only an intermediate solution until JOHNZON-177 30 | // resp https://github.com/eclipse-ee4j/jsonb-api/issues/82 is properly specced 31 | if (value < -128 || value > 255) { 32 | throw new java.lang.ArithmeticException("Overflow"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/reflection/JohnzonCollectionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.reflection; 20 | 21 | public abstract class JohnzonCollectionType extends JohnzonParameterizedType { 22 | public JohnzonCollectionType() { 23 | super(null); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/reflection/JohnzonListType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.reflection; 20 | 21 | import java.util.List; 22 | 23 | public abstract class JohnzonListType extends JohnzonCollectionType> { 24 | } 25 | -------------------------------------------------------------------------------- /johnzon-mapper/src/main/java/org/apache/johnzon/mapper/reflection/Records.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.reflection; 20 | 21 | import java.lang.reflect.InvocationTargetException; 22 | import java.lang.reflect.Method; 23 | 24 | public final class Records { 25 | private static final Method IS_RECORD; 26 | 27 | static { 28 | Method isRecord = null; 29 | try { 30 | isRecord = Class.class.getMethod("isRecord"); 31 | } catch (final NoSuchMethodException e) { 32 | // no-op 33 | } 34 | IS_RECORD = isRecord; 35 | } 36 | 37 | private Records() { 38 | // no-op 39 | } 40 | 41 | public static boolean isRecord(final Class clazz) { 42 | try { 43 | return IS_RECORD != null && Boolean.class.cast(IS_RECORD.invoke(clazz)); 44 | } catch (final InvocationTargetException | IllegalAccessException e) { 45 | return false; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/apache/johnzon/core/TestJsonGeneratorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.core; 20 | 21 | import jakarta.json.stream.JsonGenerator; 22 | import java.io.Writer; 23 | import java.util.Collections; 24 | 25 | /** 26 | * This class is only used for {@link org.apache.johnzon.mapper.JsonGeneratorCloseTest}. 27 | * 28 | * Since {@link JsonGeneratorImpl} is package private we need to add this 29 | * class in {@code org.apache.johnzon.core} to use {@link JsonGeneratorImpl} and wrap our 30 | * own {@link TestBufferProvider}. 31 | * 32 | * It's a little bit dirty and will be removed if anyone has a better 33 | * solution. 34 | */ 35 | public class TestJsonGeneratorFactory extends JsonGeneratorFactoryImpl { 36 | 37 | public TestJsonGeneratorFactory() { 38 | super(Collections.emptyMap()); 39 | } 40 | 41 | 42 | @Override 43 | public JsonGenerator createGenerator(Writer writer) { 44 | return new JsonGeneratorImpl(writer, TestBufferProvider.INSTANCE, false); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/apache/johnzon/mapper/CircularExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import org.junit.Test; 22 | 23 | import static org.junit.Assert.assertTrue; 24 | 25 | public class CircularExceptionTest { 26 | // note that with KnownNotOpenedJavaTypes this test will not test circular case anymore 27 | // but we still care to test exceptions don't loop so kept it 28 | @Test 29 | public void dontStackOverFlow() { 30 | final Throwable oopsImVicous = new Exception("circular"); 31 | oopsImVicous.getStackTrace(); // fill it 32 | oopsImVicous.initCause(new IllegalArgumentException(oopsImVicous)); 33 | final String serialized = new MapperBuilder().setAccessModeName("field").build().writeObjectAsString(oopsImVicous); 34 | assertTrue(serialized.contains("\"message\":\"circular\"")); 35 | assertTrue(serialized.contains("\"stackTrace\":[{")); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/apache/johnzon/mapper/GetterSetterRespectTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import org.junit.Test; 22 | 23 | import static org.junit.Assert.assertEquals; 24 | 25 | public class GetterSetterRespectTest { 26 | @Test 27 | public void run() { 28 | final Mapper mapper = new MapperBuilder().build(); 29 | assertEquals("ok", Mapped.class.cast(mapper.readObject("{\"name_\":\"ok\"}", Mapped.class)).name); 30 | 31 | final Mapped mapped = new Mapped(); 32 | mapped.name = "ok"; 33 | assertEquals("{\"_name\":\"ok\"}", mapper.writeObjectAsString(mapped)); 34 | } 35 | 36 | public static class Mapped { 37 | private String name; 38 | 39 | @JohnzonProperty("_name") 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | @JohnzonProperty("name_") 45 | public void setName(final String name) { 46 | this.name = name; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/apache/johnzon/mapper/MapperBeanGetterUserExceptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.johnzon.mapper; 18 | 19 | import org.junit.Test; 20 | 21 | public class MapperBeanGetterUserExceptionsTest { 22 | 23 | private static final RuntimeException USER_EXCEPTION = new RuntimeException("I am user, hear me roar"); 24 | 25 | @Test 26 | public void object() { 27 | ExceptionAsserts.fromMapperWriteObject(new Widget()) 28 | .assertInstanceOf(MapperException.class) 29 | .assertMessage("Error calling public java.lang.String org.apache.johnzon.mapper.MapperBeanGetter" + 30 | "UserExceptionsTest$Widget.getString()") 31 | .assertCauseChain(USER_EXCEPTION); 32 | } 33 | 34 | public static class Widget { 35 | private String string; 36 | 37 | public String getString() { 38 | throw USER_EXCEPTION; 39 | } 40 | 41 | public void setString(final String string) { 42 | this.string = string; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/apache/johnzon/mapper/SerializeValueFilterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper; 20 | 21 | import org.junit.Test; 22 | 23 | import java.util.Collection; 24 | import java.util.List; 25 | 26 | import static java.util.Collections.singleton; 27 | import static java.util.Collections.singletonList; 28 | import static org.junit.Assert.assertEquals; 29 | 30 | public class SerializeValueFilterTest { 31 | @Test 32 | public void customIgnore() { 33 | // in this test we will serialize lists but not sets or other collection impls 34 | final Mapper mapper = new MapperBuilder().setSerializeValueFilter((name, value) -> !List.class.isInstance(value)).build(); 35 | assertEquals("{\"list\":[\"test\"]}", mapper.writeObjectAsString(new Foo(singletonList("test")))); 36 | assertEquals("{}", mapper.writeObjectAsString(new Foo(singleton("test")))); 37 | } 38 | 39 | public static class Foo { 40 | public Collection list; 41 | 42 | public Foo(final Collection list) { 43 | this.list = list; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/apache/johnzon/mapper/converter/EnumConverterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.junit.Test; 22 | 23 | import static org.junit.Assert.assertEquals; 24 | 25 | public class EnumConverterTest { 26 | @Test 27 | public void fromEnumToString() { 28 | assertEquals("B", new EnumConverter(AnEnum.class).toString(AnEnum.B)); 29 | } 30 | 31 | @Test 32 | public void fromStringToEnum() { 33 | assertEquals(AnEnum.B, new EnumConverter(AnEnum.class).fromString("B")); 34 | } 35 | 36 | public enum AnEnum { 37 | A, B 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/apache/johnzon/mapper/converter/UUIDConverterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.converter; 20 | 21 | import org.apache.johnzon.mapper.Mapper; 22 | import org.apache.johnzon.mapper.MapperBuilder; 23 | import org.junit.jupiter.api.Test; 24 | 25 | import java.util.UUID; 26 | 27 | import static org.junit.Assert.assertEquals; 28 | 29 | public class UUIDConverterTest { 30 | private static final UUID THE_UUID = UUID.randomUUID(); 31 | 32 | @Test 33 | public void serialize() { 34 | Mapper mapper = new MapperBuilder().build(); 35 | String json = mapper.writeObjectAsString(THE_UUID); 36 | 37 | assertEquals("\"" + THE_UUID + "\"", json); 38 | } 39 | 40 | @Test 41 | public void deserialize() { 42 | Mapper mapper = new MapperBuilder().build(); 43 | UUID uuid = mapper.readObject("\"" + THE_UUID + "\"", UUID.class); 44 | 45 | assertEquals(THE_UUID, uuid); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/apache/johnzon/mapper/internal/JsonPointerTrackerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.mapper.internal; 20 | 21 | import org.junit.Assert; 22 | import org.junit.Test; 23 | 24 | public class JsonPointerTrackerTest { 25 | 26 | 27 | @Test 28 | public void testJsonPointerTracker() { 29 | JsonPointerTracker jptRoot = JsonPointerTracker.ROOT; 30 | 31 | Assert.assertEquals("/", jptRoot.toString()); 32 | 33 | JsonPointerTracker jptAttrL1 = new JsonPointerTracker(jptRoot, "attrL1"); 34 | JsonPointerTracker jptAttrL2 = new JsonPointerTracker(jptAttrL1, "attrL2"); 35 | 36 | Assert.assertEquals("/attrL1/attrL2", jptAttrL2.toString()); 37 | Assert.assertEquals("/attrL1", jptAttrL1.toString()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/superbiz/Model.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.superbiz; 20 | 21 | public class Model extends ModelBase { 22 | public static class ChildA extends ModelSuperBase.ChildA { 23 | public String detail; 24 | } 25 | 26 | public static class ChildB extends ModelSuperBase.ChildB { 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/superbiz/ModelBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.superbiz; 20 | 21 | import java.util.Collection; 22 | 23 | public abstract class ModelBase 24 | extends ModelSuperBase { 25 | private Collection aalist; 26 | 27 | public Collection getAalist() { 28 | return aalist; 29 | } 30 | 31 | public void setAalist(final Collection aalist) { 32 | this.aalist = aalist; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/superbiz/ModelSuperBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.superbiz; 20 | 21 | public abstract class ModelSuperBase 22 | extends ModelSuperSuperBase { 23 | public static class ChildA extends ModelSuperSuperBase.ChildA { 24 | 25 | } 26 | 27 | public static class ChildB extends ModelSuperSuperBase.ChildB { 28 | 29 | } 30 | 31 | private A childA; 32 | private B childB; 33 | 34 | @Override 35 | public A getChildA() { 36 | return childA; 37 | } 38 | 39 | @Override 40 | public void setChildA(A childA) { 41 | this.childA = childA; 42 | } 43 | 44 | @Override 45 | public B getChildB() { 46 | return childB; 47 | } 48 | 49 | @Override 50 | public void setChildB(B childB) { 51 | this.childB = childB; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/superbiz/ModelSuperSuperBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.superbiz; 20 | 21 | public abstract class ModelSuperSuperBase { 22 | public static class ChildA { 23 | public String name; 24 | } 25 | 26 | public static class ChildB { 27 | 28 | } 29 | 30 | private A childA; 31 | private B childB; 32 | 33 | public A getChildA() { 34 | return childA; 35 | } 36 | 37 | public void setChildA(A childA) { 38 | this.childA = childA; 39 | } 40 | 41 | public B getChildB() { 42 | return childB; 43 | } 44 | 45 | public void setChildB(B childB) { 46 | this.childB = childB; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/java/org/superbiz/MultiStructureObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.superbiz; 20 | 21 | import java.util.Collection; 22 | import java.util.Map; 23 | 24 | public class MultiStructureObject { 25 | public Map polymorphic; 26 | public String data; 27 | public Collection nesteds; 28 | public Map nestedMap; 29 | public Collection names; 30 | public int[] anArray; 31 | 32 | public static class Nested { 33 | public int number; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /johnzon-mapper/src/test/resources/JPATest.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 24 | 25 | org.apache.johnzon.mapper.JPATest$AnEntity 26 | true 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /johnzon-maven-plugin/.gitattributes: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 Markus KARG 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | src/test/resources/SomeValue.java text eol=lf 16 | 17 | -------------------------------------------------------------------------------- /johnzon-osgi/src/main/java/org/apache/johnzon/osgi/cdi/CdiExtensionFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.johnzon.osgi.cdi; 21 | 22 | import jakarta.enterprise.inject.spi.Extension; 23 | 24 | import org.apache.johnzon.jsonb.cdi.JohnzonCdiExtension; 25 | import org.osgi.framework.Bundle; 26 | import org.osgi.framework.PrototypeServiceFactory; 27 | import org.osgi.framework.ServiceRegistration; 28 | 29 | public class CdiExtensionFactory implements PrototypeServiceFactory { 30 | 31 | @Override 32 | public Extension getService(Bundle bundle, ServiceRegistration registration) { 33 | return new JohnzonCdiExtension(); 34 | } 35 | 36 | @Override 37 | public void ungetService(Bundle bundle, ServiceRegistration registration, Extension service) { 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /johnzon-osgi/src/main/java/org/apache/johnzon/osgi/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | @Capability(namespace = SERVICE_NAMESPACE, 21 | attribute = { 22 | JAX_RS_MEDIA_TYPE + "=" + APPLICATION_JSON, 23 | "objectClass:List='jakarta.ws.rs.ext.MessageBodyReader,jakarta.ws.rs.ext.MessageBodyWriter'"}) 24 | package org.apache.johnzon.osgi; 25 | 26 | import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; 27 | import static org.osgi.namespace.service.ServiceNamespace.SERVICE_NAMESPACE; 28 | import static org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_MEDIA_TYPE; 29 | 30 | import org.osgi.annotation.bundle.Capability; 31 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/internal/jsr/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | /** 20 | * This package is considered to be beta state 21 | */ 22 | package org.apache.johnzon.websocket.internal.jsr; 23 | 24 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/internal/lazy/LazySupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.internal.lazy; 20 | 21 | import java.util.function.Supplier; 22 | 23 | public class LazySupplier implements Supplier { 24 | private Supplier delegate; 25 | private volatile T instance; 26 | 27 | public LazySupplier(final Supplier provider) { 28 | this.delegate = provider; 29 | } 30 | 31 | @Override 32 | public T get() { 33 | if (instance == null) { 34 | synchronized (this) { 35 | if (instance == null) { 36 | instance = delegate.get(); 37 | delegate = null; 38 | } 39 | } 40 | } 41 | return instance; 42 | } 43 | 44 | public T getInstance() { 45 | return instance; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/internal/mapper/MapperLocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.internal.mapper; 20 | 21 | import org.apache.johnzon.websocket.internal.servlet.IgnoreIfMissing; 22 | 23 | import jakarta.servlet.annotation.WebListener; 24 | 25 | @WebListener // since people move to json-b we make this init lazy 26 | public class MapperLocator extends IgnoreIfMissing { 27 | public MapperLocator() { 28 | super(() -> new MapperLocatorDelegate()); 29 | } 30 | 31 | public static Object locate() { 32 | return MapperLocatorDelegate.locate(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/internal/mapper/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | /** 20 | * This package is considered to be beta state 21 | */ 22 | package org.apache.johnzon.websocket.internal.mapper; 23 | 24 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/internal/servlet/IgnoreIfMissing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.internal.servlet; 20 | 21 | import jakarta.servlet.ServletContextEvent; 22 | import jakarta.servlet.ServletContextListener; 23 | import java.util.function.Supplier; 24 | 25 | public class IgnoreIfMissing implements ServletContextListener { 26 | private final Supplier delegate; 27 | private boolean skipped; 28 | 29 | public IgnoreIfMissing(final Supplier delegate) { 30 | this.delegate = delegate; 31 | } 32 | 33 | @Override 34 | public void contextInitialized(final ServletContextEvent sce) { 35 | try { 36 | delegate.get().contextInitialized(sce); 37 | } catch (final Error | RuntimeException re) { 38 | skipped = true; 39 | } 40 | } 41 | 42 | @Override 43 | public void contextDestroyed(final ServletContextEvent sce) { 44 | if (!skipped) { 45 | delegate.get().contextDestroyed(sce); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/jsonb/JsonbLocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.jsonb; 20 | 21 | import org.apache.johnzon.websocket.internal.servlet.IgnoreIfMissing; 22 | 23 | import jakarta.servlet.annotation.WebListener; 24 | 25 | @WebListener 26 | public class JsonbLocator extends IgnoreIfMissing { 27 | public JsonbLocator() { 28 | super(() -> new JsonbLocatorDelegate()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/jsonb/JsonbTextEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.jsonb; 20 | 21 | import jakarta.json.bind.Jsonb; 22 | import jakarta.json.bind.JsonbException; 23 | import jakarta.websocket.EncodeException; 24 | import jakarta.websocket.Encoder; 25 | import jakarta.websocket.EndpointConfig; 26 | import java.io.Writer; 27 | 28 | public class JsonbTextEncoder implements Encoder.TextStream { 29 | private Jsonb jsonb; 30 | 31 | @Override 32 | public void init(final EndpointConfig endpointConfig) { 33 | jsonb = JsonbLocatorDelegate.locate(); 34 | } 35 | 36 | @Override 37 | public void destroy() { 38 | // no-op 39 | } 40 | 41 | @Override 42 | public void encode(final Object object, final Writer writer) throws EncodeException { 43 | try { 44 | jsonb.toJson(object, writer); 45 | } catch (final JsonbException je) { 46 | throw new EncodeException(object, je.getMessage(), je); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/jsr/JsrArrayDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.jsr; 20 | 21 | import org.apache.johnzon.websocket.internal.jsr.JsrDecoder; 22 | 23 | import jakarta.json.JsonArray; 24 | import jakarta.json.JsonReader; 25 | 26 | public class JsrArrayDecoder extends JsrDecoder { 27 | @Override 28 | protected JsonArray doRead(JsonReader jsonReader) { 29 | return jsonReader.readArray(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/jsr/JsrArrayEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.jsr; 20 | 21 | import org.apache.johnzon.websocket.internal.jsr.JsrEncoder; 22 | 23 | import jakarta.json.JsonArray; 24 | import jakarta.json.JsonWriter; 25 | 26 | public class JsrArrayEncoder extends JsrEncoder { 27 | @Override 28 | protected void doWrite(final JsonWriter writer, final JsonArray array) { 29 | writer.writeArray(array); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/jsr/JsrObjectDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.jsr; 20 | 21 | import org.apache.johnzon.websocket.internal.jsr.JsrDecoder; 22 | 23 | import jakarta.json.JsonObject; 24 | import jakarta.json.JsonReader; 25 | import jakarta.json.JsonReaderFactory; 26 | 27 | public class JsrObjectDecoder extends JsrDecoder { 28 | private JsonReaderFactory factory; 29 | 30 | @Override 31 | protected JsonObject doRead(final JsonReader jsonReader) { 32 | return jsonReader.readObject(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/jsr/JsrObjectEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.jsr; 20 | 21 | import org.apache.johnzon.websocket.internal.jsr.JsrEncoder; 22 | 23 | import jakarta.json.JsonObject; 24 | import jakarta.json.JsonWriter; 25 | 26 | public class JsrObjectEncoder extends JsrEncoder { 27 | @Override 28 | protected void doWrite(final JsonWriter writer, final JsonObject jsonObject) { 29 | writer.writeObject(jsonObject); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/jsr/JsrStructureDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.jsr; 20 | 21 | import org.apache.johnzon.websocket.internal.jsr.JsrDecoder; 22 | 23 | import jakarta.json.JsonReader; 24 | import jakarta.json.JsonReaderFactory; 25 | import jakarta.json.JsonStructure; 26 | 27 | public class JsrStructureDecoder extends JsrDecoder { 28 | private JsonReaderFactory factory; 29 | 30 | @Override 31 | protected JsonStructure doRead(final JsonReader jsonReader) { 32 | return jsonReader.read(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/jsr/JsrStructureEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.jsr; 20 | 21 | import org.apache.johnzon.websocket.internal.jsr.JsrEncoder; 22 | 23 | import jakarta.json.JsonStructure; 24 | import jakarta.json.JsonWriter; 25 | 26 | public class JsrStructureEncoder extends JsrEncoder { 27 | @Override 28 | protected void doWrite(final JsonWriter writer, final JsonStructure structure) { 29 | writer.write(structure); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/jsr/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | /** 20 | * This package is considered to be beta state 21 | */ 22 | package org.apache.johnzon.websocket.jsr; 23 | 24 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/mapper/JohnzonTextEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.mapper; 20 | 21 | import org.apache.johnzon.mapper.Mapper; 22 | import org.apache.johnzon.websocket.internal.mapper.MapperLocator; 23 | 24 | import jakarta.websocket.EncodeException; 25 | import jakarta.websocket.Encoder; 26 | import jakarta.websocket.EndpointConfig; 27 | import java.io.IOException; 28 | import java.io.Writer; 29 | 30 | public class JohnzonTextEncoder implements Encoder.TextStream { 31 | private Mapper mapper; 32 | 33 | @Override 34 | public void init(final EndpointConfig endpointConfig) { 35 | mapper = Mapper.class.cast(MapperLocator.locate()); 36 | } 37 | 38 | @Override 39 | public void destroy() { 40 | // no-op 41 | } 42 | 43 | @Override 44 | public void encode(final Object object, final Writer writer) throws EncodeException, IOException { 45 | mapper.writeObject(object, writer); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /johnzon-websocket/src/main/java/org/apache/johnzon/websocket/mapper/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | /** 20 | * This package is considered to be beta state 21 | */ 22 | package org.apache.johnzon.websocket.mapper; 23 | 24 | -------------------------------------------------------------------------------- /johnzon-websocket/src/test/java/org/apache/johnzon/websocket/endpoint/ClientEndpointImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.endpoint; 20 | 21 | import org.apache.johnzon.websocket.mapper.JohnzonTextDecoder; 22 | import org.apache.johnzon.websocket.mapper.JohnzonTextEncoder; 23 | 24 | import java.util.LinkedList; 25 | import java.util.List; 26 | import java.util.concurrent.Semaphore; 27 | import jakarta.websocket.ClientEndpoint; 28 | import jakarta.websocket.OnMessage; 29 | 30 | @ClientEndpoint(encoders = JohnzonTextEncoder.class, decoders = ClientEndpointImpl.MessageDecoder.class) 31 | public class ClientEndpointImpl { 32 | public static final List MESSAGES = new LinkedList(); 33 | public static final Semaphore SEMAPHORE = new Semaphore(0); 34 | 35 | @OnMessage 36 | public synchronized void on(final Message message) { 37 | MESSAGES.add(message); 38 | SEMAPHORE.release(); 39 | } 40 | 41 | public static class MessageDecoder extends JohnzonTextDecoder { 42 | public MessageDecoder() { 43 | super(Message.class); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /johnzon-websocket/src/test/java/org/apache/johnzon/websocket/endpoint/JsrClientEndpointImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.endpoint; 20 | 21 | import org.apache.johnzon.websocket.jsr.JsrObjectDecoder; 22 | import org.apache.johnzon.websocket.jsr.JsrObjectEncoder; 23 | 24 | import java.util.LinkedList; 25 | import java.util.List; 26 | import java.util.concurrent.Semaphore; 27 | import jakarta.json.JsonObject; 28 | import jakarta.websocket.ClientEndpoint; 29 | import jakarta.websocket.OnMessage; 30 | 31 | @ClientEndpoint(encoders = JsrObjectEncoder.class, decoders = JsrObjectDecoder.class) 32 | public class JsrClientEndpointImpl { 33 | public static final List MESSAGES = new LinkedList(); 34 | public static final Semaphore SEMAPHORE = new Semaphore(0); 35 | 36 | @OnMessage 37 | public synchronized void on(final JsonObject message) { 38 | MESSAGES.add(message); 39 | SEMAPHORE.release(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /johnzon-websocket/src/test/java/org/apache/johnzon/websocket/endpoint/Message.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.johnzon.websocket.endpoint; 20 | 21 | import jakarta.xml.bind.annotation.XmlRootElement; 22 | 23 | @XmlRootElement // old tomee default json provider (pre-johnzon erea) was using jaxb 24 | public class Message { 25 | private String value; 26 | 27 | public Message() { 28 | // no-op 29 | } 30 | 31 | public Message(final String msg) { 32 | this.value = msg; 33 | } 34 | 35 | public String getValue() { 36 | return value; 37 | } 38 | 39 | public void setValue(final String value) { 40 | this.value = value; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /johnzon-websocket/src/test/resources/arquillian.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 25 | 26 | 27 | -1 28 | -1 29 | -1 30 | -1 31 | true 32 | true 33 | target/apache-tomee-remote 34 | target/arquillian-test-working-dir 35 | ${arquillian.jvm.args} 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /siteDeploy.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | 21 | mvn clean verify site site:stage $@ 22 | mvn scm-publish:publish-scm $@ 23 | -------------------------------------------------------------------------------- /src/site/resources/images/johnzon_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/johnzon/e75e87e76edd882a39017b4d1c205e972f131cb8/src/site/resources/images/johnzon_logo.png --------------------------------------------------------------------------------