Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement JsonNoCanonicalizeReadVanilla #8

Open
wants to merge 1 commit into
base: 2.15
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.fasterxml.jackson.perf.json;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.perf.ReadPerfBaseFullJackson;
import com.fasterxml.jackson.perf.data.InputConverter;
import com.fasterxml.jackson.perf.model.MediaItem;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;

import java.util.concurrent.TimeUnit;

@State(Scope.Thread)
@OutputTimeUnit(TimeUnit.SECONDS)
public class JsonNoCanonicalizeReadVanilla
extends ReadPerfBaseFullJackson<MediaItem>
{
private static final ObjectMapper MAPPER = JsonMapper.builder(
JsonFactory.builder()
.disable(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES)
.build())
.build();

// pass non-null ObjectMapper: will remove whitespace, if any
private final static InputConverter JSON_CONV = InputConverter.stdConverter(MAPPER);

// NOTE: to _RETAIN_ whitespace, we'd use:
// private final static InputConverter JSON_CONV = InputConverter.nopConverter(MAPPER);

public JsonNoCanonicalizeReadVanilla() {
super(MediaItem.class, JSON_CONV, MAPPER);
}
}