Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ name: build pull request
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened ]

types: [opened, synchronize, reopened]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -18,7 +17,6 @@ jobs:
env:
MAVEN_ARGS: '--no-transfer-progress'
steps:

- uses: actions/checkout@v6
- name: Set up JDK
uses: actions/setup-java@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/touch-javadocio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
push:
paths:
- pom.xml
branches: ['**']
branches: ['main', 'REL-*']
workflow_dispatch:


Expand Down
42 changes: 26 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
<spring.version>6.2.13</spring.version>
<spring-security.version>6.5.6</spring-security.version>
<jackson2.version>2.20.1</jackson2.version>
<jackson3.version>3.0.3</jackson3.version>

<junit.version>6.0.1</junit.version>
<mockito.version>5.20.0</mockito.version>
<junit.version>6.0.2</junit.version>
<mockito.version>5.21.0</mockito.version>
<assertj.version>3.27.6</assertj.version>
<resteasy.version>7.0.0.Final</resteasy.version>

Expand All @@ -32,17 +33,17 @@
-->
<jboss-logging.version>3.6.1.Final</jboss-logging.version>

<bytebuddy.version>1.18.1</bytebuddy.version>
<bytebuddy.version>1.18.3</bytebuddy.version>
<slf4j.version>2.0.17</slf4j.version>
<log4j2.version>2.25.2</log4j2.version>
<log4j2.version>2.25.3</log4j2.version>
<guava.version>33.5.0-jre</guava.version>
<javassist.version>3.30.2-GA</javassist.version>
<wss4j.version>2.3.2</wss4j.version>
<xmlunit.version>2.11.0</xmlunit.version>
<hamcrest.version>3.0</hamcrest.version>
<math.version>0.18.1</math.version>
<meeuw.util.version>1.15</meeuw.util.version>
<checker.version>3.52.0</checker.version>
<checker.version>3.53.0</checker.version>

<httpcomponents.version>4.5.14</httpcomponents.version>
<httpcomponentscore.version>4.4.16</httpcomponentscore.version>
Expand All @@ -60,7 +61,7 @@
<hibernate.validator.version>9.0.1.Final</hibernate.validator.version>
<camel.version>4.16.0</camel.version> <!-- limit to LTS (I think even majors) -->

<swagger.version>2.2.40</swagger.version>
<swagger.version>2.2.41</swagger.version>

<lombok.version>1.18.42</lombok.version>
<delombok.output>${project.build.directory}/delombok</delombok.output>
Expand All @@ -72,10 +73,10 @@
<elasticsearch7.version>7.13.4</elasticsearch7.version>
<lucene.elasticsearch7.version>8.8.2</lucene.elasticsearch7.version>

<micrometer.version>1.16.0</micrometer.version>
<flyway.version>11.16.0</flyway.version>
<micrometer.version>1.16.1</micrometer.version>
<flyway.version>11.20.1</flyway.version>

<testcontainers.version>2.0.2</testcontainers.version>
<testcontainers.version>2.0.3</testcontainers.version>

<EXTRA_TEST_OPTS>--add-opens java.base/java.lang=ALL-UNNAMED</EXTRA_TEST_OPTS>
<vpro.shared.module.postfix>OVERRIDE</vpro.shared.module.postfix>
Expand Down Expand Up @@ -136,6 +137,8 @@
<module>vpro-shared-hibernate-search6</module>

<module>vpro-shared-jackson2</module>
<module>vpro-shared-jackson3</module>

<module>vpro-shared-logging</module>
<module>vpro-shared-log4j2</module>
<module>vpro-shared-monitoring</module>
Expand Down Expand Up @@ -469,17 +472,17 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.19.0</version>
<version>3.20.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.14.0</version>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-configuration2</artifactId>
<version>2.12.0</version>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>io.github.natty-parser</groupId>
Expand Down Expand Up @@ -587,6 +590,13 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>tools.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>${jackson3.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand Down Expand Up @@ -638,7 +648,7 @@
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.21.2</version>
<version>1.22.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
Expand Down Expand Up @@ -714,7 +724,7 @@
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>3.13.1</version>
<version>3.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -751,7 +761,7 @@
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>5.0.2</version>
<version>5.0.3</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
Expand Down Expand Up @@ -783,7 +793,7 @@
<dependency>
<groupId>org.meeuw</groupId>
<artifactId>mihxil-json-grep</artifactId>
<version>0.13</version>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
Expand Down
5 changes: 5 additions & 0 deletions vpro-shared-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@
<artifactId>vpro-shared-jackson2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>nl.vpro.shared</groupId>
<artifactId>vpro-shared-jackson3</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>nl.vpro.shared</groupId>
<artifactId>vpro-shared-logging</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions vpro-shared-i18n/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,10 @@
<artifactId>swagger-annotations-jakarta</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>nl.vpro.shared</groupId>
<artifactId>vpro-shared-logging</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
4 changes: 0 additions & 4 deletions vpro-shared-jackson2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ Also `nl.vpro.jackson2.Views` is provided which defines a few classes which can

This package also contains `nl.vpro.jackson2.JsonArrayIterator`. A tool to wrap, using jackson, a stream of json object into an iterator of java objects.


## AfterUnmarshallDeserializer

Jackson lacks support for `#afterUnmarshall'. The 'nl.vpro.jackson2.AfterUnmarshalDeserializer' deserializer adds it. This can e.g. be used to add references to parent objects.
10 changes: 5 additions & 5 deletions vpro-shared-jackson2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>io.github.natty-parser</groupId>
<artifactId>natty</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.github.natty-parser</groupId>
<artifactId>natty</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

public class GuavaRangeModule extends SimpleModule {

public static final String LOWER_ENDPOINT = "lowerEndpoint";
public static final String LOWER_ENDPOINT = "lowerEndpoint";
public static final String LOWER_BOUND_TYPE = "lowerBoundType";
public static final String UPPER_ENDPOINT = "upperEndpoint";
public static final String UPPER_ENDPOINT = "upperEndpoint";
public static final String UPPER_BOUND_TYPE = "upperBoundType";

@Serial
Expand Down Expand Up @@ -137,6 +137,4 @@ static <C extends Comparable<C>> Range<C> of(Class<C> clazz, JsonParser p, JsonN
}
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationIntrospector;
import com.google.common.annotations.Beta;

import nl.vpro.jackson.Views;
import nl.vpro.logging.simple.SimpleLogger;
import nl.vpro.util.LoggingInputStream;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ private JsonArrayIterator(
}
this.eventListener.accept(new TokenEvent(token));
if (token == JsonToken.FIELD_NAME) {
fieldName = jp.getCurrentName();
fieldName = jp.currentName();
}
if (token == JsonToken.VALUE_NUMBER_INT && sizeField.equals(fieldName)) {
tmpSize = jp.getLongValue();
this.eventListener.accept(new SizeEvent(tmpSize));
}
if (token == JsonToken.VALUE_NUMBER_INT && totalSizeField.equals(fieldName)) {
tmpTotalSize = jp.getLongValue();
this.eventListener.accept(new TotalSizeEvent(tmpSize));
this.eventListener.accept(new TotalSizeEvent(tmpTotalSize));

}
if (token == JsonToken.START_ARRAY) {
Expand Down Expand Up @@ -212,7 +212,9 @@ protected void findNext() {
while(true) {
try {
TreeNode tree = jp.readValueAsTree();
this.eventListener.accept(new TokenEvent(jp.getLastClearedToken()));
var newLastToken = jp.getLastClearedToken();

this.eventListener.accept(new TokenEvent(newLastToken));

if (jp.getLastClearedToken() == JsonToken.END_ARRAY) {
tree = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;

import nl.vpro.util.NattySupport;

/**
* These can be used in conjunction with InstantXmlAdapter, if you want 'millis since epoch' in JSON, but formatted date stamps in xml.
* (this is what we normally do)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationIntrospector;

import nl.vpro.jackson.Views;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
Expand All @@ -37,6 +44,27 @@ public static class A {
Optional<Integer> optional;
}


@Test

public void basicJackson2() throws JsonProcessingException {
JsonMapper mapper = new JsonMapper();
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(
new JacksonAnnotationIntrospector(),
new JakartaXmlBindAnnotationIntrospector(mapper.getTypeFactory()))
);
mapper.registerModule(new Jdk8Module());

A a = mapper.readerWithView(Views.Normal.class).forType(A.class)
.readValue("""
{"integer": 2, "optional": 3}
""");
assertThat(a.integer).isEqualTo(2);
assertThat(a.optional).contains(3);

}


@Test
public void read() throws IOException {
String example = "/* leading comments */\n{'integer': 2 /* ignore comments */, 'optional': 3}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.*;

import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
Expand All @@ -25,8 +24,32 @@
@Slf4j
public class JsonArrayIteratorTest {


@Test
public void simple() throws IOException {
try (JsonArrayIterator<Change> i = JsonArrayIterator.<Change>builder().valueClass(Change.class)
.inputStream(
new ByteArrayInputStream("""
{
"size": 1,
"changes": [
{
"sequence": 724,
"revision": 2,
"mid": "POMS_NCRV_1138990",
"deleted": true
}
}
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The closing bracket for the array is missing on this line. There should be a closing bracket ] after line 42.

Suggested change
}
]

Copilot uses AI. Check for mistakes.
}
""".getBytes(StandardCharsets.UTF_8))).build()) {
Change change = i.next();
log.info("{}", change);

}
}

@Test
public void test() throws IOException {
public void changes() throws IOException {

//Jackson2Mapper.getInstance().writeValue(System.out, new Change("bla", false));
try (JsonArrayIterator<Change> it = JsonArrayIterator.<Change>builder().inputStream(getClass().getResourceAsStream("/changes.json")).valueClass(Change.class).objectMapper(Jackson2Mapper.getInstance()).build()) {
Expand All @@ -43,6 +66,7 @@ public void test() throws IOException {
);
if (!change.isDeleted()) {
assertThat(change.getMedia()).isNotNull();
assertThat(change.getMedia()).isInstanceOf(Map.class);
}
}
assertThat(it.hasNext()).isTrue(); // 11
Expand Down
16 changes: 16 additions & 0 deletions vpro-shared-jackson3/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
= Jackson3 utilities

image:http://www.javadoc.io/badge/nl.vpro.shared/vpro-shared-jackson3.svg?color=blue[javadoc,link=http://www.javadoc.io/doc/nl.vpro.shared/vpro-shared-jackson3]



We collect some generic Jackson3 utilities. Mainly `tools.jackson.databind.ValueSerializer`s and `tools.jackson.databind.ValueDeserializer`s.

Some of them are bundled in modules. E.g. a `nl.vpro.jackson3.DateModule`, which can will make a `tools.jackson.databind.ObjectMapper` recognize `java.time` classes
(but a bit differently then `com.fasterxml.jackson.datatype.jsr310.JavaTimeModule` does, which it predates).

Also `nl.vpro.jackson2.Views` is provided which defines a few classes which can be used with `@com.fasterxml.jackson.annotation.JsonView`.

== JsonArrayIterator

This package also contains `nl.vpro.jackson3.JsonArrayIterator`. A tool to wrap, using jackson, a stream of json object into an iterator of java objects.
Loading
Loading