Skip to content

Commit

Permalink
Remove deprecated usage of JsonNodeFactory.withExactBigDecimals(true)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Jul 11, 2023
1 parent acf1fb6 commit 2a842d9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class JsonArrayEntrySerDes extends JacksonJsonSerDes<JsonArrayEntry> {

@Override
public JsonNode jSerialize(JsonArrayEntry jae) throws JsonException {
ObjectNode o = JsonNodeFactory.withExactBigDecimals(true).objectNode();
ObjectNode o = JsonNodeFactory.instance.objectNode();
if (jae.getName() != null)
o.put("n", jae.getName());
Type type = jae.getType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

public class JsonRootObjectSerDes extends JacksonJsonSerDes<JsonRootObject> {

private JsonArrayEntrySerDes serDes = new JsonArrayEntrySerDes();
private final JsonArrayEntrySerDes serDes = new JsonArrayEntrySerDes();

@Override
public JsonNode jSerialize(JsonRootObject jro) throws JsonException {
ObjectNode o = JsonNodeFactory.withExactBigDecimals(true).objectNode();
ObjectNode o = JsonNodeFactory.instance.objectNode();

if (jro.getBaseName() != null)
o.put("bn", jro.getBaseName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@
import org.eclipse.leshan.core.util.json.JsonException;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.cfg.JsonNodeFeature;

/**
* Helper for encoding/decoding LWM2M JSON format using jackson
*/
public class LwM2mJsonJacksonEncoderDecoder implements LwM2mJsonDecoder, LwM2mJsonEncoder {

private static final JsonRootObjectSerDes serDes = new JsonRootObjectSerDes();
private static final ObjectMapper mapper = new ObjectMapper();
private static final ObjectMapper mapper = new ObjectMapper()
.configure(JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES, false);

@Override
public String toJsonLwM2m(JsonRootObject jro) throws LwM2mJsonException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.cfg.JsonNodeFeature;

/**
* Helper for encoding/decoding SenML JSON using Jackson
*/
public class SenMLJsonJacksonEncoderDecoder implements SenMLDecoder, SenMLEncoder {
private final JacksonJsonSerDes<SenMLRecord> serDes;
private static final ObjectMapper mapper = new ObjectMapper();
private static final ObjectMapper mapper = new ObjectMapper()
.configure(JsonNodeFeature.STRIP_TRAILING_BIGDECIMAL_ZEROES, false);

public SenMLJsonJacksonEncoderDecoder() {
this(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public SenMLJsonRecordSerDes(boolean allowNoValue, Base64Decoder base64Decoder,

@Override
public JsonNode jSerialize(SenMLRecord record) throws JsonException {
ObjectNode jsonObj = JsonNodeFactory.withExactBigDecimals(true).objectNode();
ObjectNode jsonObj = JsonNodeFactory.instance.objectNode();

if (record.getBaseName() != null && record.getBaseName().length() > 0) {
jsonObj.put("bn", record.getBaseName());
Expand Down

0 comments on commit 2a842d9

Please sign in to comment.