From 0617ccfc0ab220aa1cab29280ac64182862906d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Merino=20Garc=C3=ADa?= Date: Sat, 30 Jan 2021 20:45:45 +0100 Subject: [PATCH] Remove my dsljson (#164) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 💡 remove mydsl-json dependency * ci: 🎡 9.0.0 version --- docs/CHANGELOG.md | 9 ++++---- docs/README.md | 21 ++++++++++++------- pom.xml | 12 +++++------ .../java/com/dslplatform/json/MyDslJson.java | 2 +- .../json/parsers/JsDecimalParser.java | 10 ++++----- .../dslplatform/json/parsers/JsIntParser.java | 11 +++++----- .../json/parsers/JsIntegralParser.java | 14 ++++++------- .../json/parsers/JsLongParser.java | 10 ++++----- src/test/java/jsonvalues/TestJsParser.java | 5 ++--- 9 files changed, 50 insertions(+), 44 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7958c16d..d8ee65eb 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,9 +1,10 @@ # JSON-VALUES -## v9.0.0-RC2 ( Fri Jan 15 2021 18:58:37 GMT+0100 (Central European Standard Time) ) +## v9.0.0 ( Sat Jan 30 2021 20:39:00 GMT+0100 (Central European Standard Time) ) -## Features - - 🎸 streamValues methods - ([900da162](https://github.com/imrafaelmerino/json-values/commit/900da162a328a704b878f405b28a8da5983e30d1)) + +## Refactor + - 💡 remove mydsl-json dependency + ([66c7a1de](https://github.com/imrafaelmerino/json-values/commit/66c7a1de4646a250f3680a4ea840c1fd4e0b0a54)) diff --git a/docs/README.md b/docs/README.md index 236db6e7..7940fe75 100644 --- a/docs/README.md +++ b/docs/README.md @@ -9,7 +9,7 @@ [![Javadocs](https://www.javadoc.io/badge/com.github.imrafaelmerino/json-values.svg)](https://www.javadoc.io/doc/com.github.imrafaelmerino/json-values) -[![Maven](https://img.shields.io/maven-central/v/com.github.imrafaelmerino/json-values/9.0.0-RC3)](https://search.maven.org/artifact/com.github.imrafaelmerino/json-values/9.0.0-RC3/jar) +[![Maven](https://img.shields.io/maven-central/v/com.github.imrafaelmerino/json-values/9.0.0)](https://search.maven.org/artifact/com.github.imrafaelmerino/json-values/9.0.0/jar) [![](https://jitpack.io/v/imrafaelmerino/json-values.svg)](https://jitpack.io/#imrafaelmerino/json-values) [![Gitter](https://badges.gitter.im/json-values/community.svg)](https://gitter.im/json-values/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) @@ -44,15 +44,22 @@ in Java 8, like functions, suppliers, streams, and collectors, making json manip leave the functions passed in as arguments with no implementation for brevity reasons. ```java -json.mapKeys(toSneakeCase) +JsObj a = JsOJsObj.parse(json) +JsObj b = JsOJsObj.parseYaml(yaml) -json.mapValues(trim, ifStr) +// first level +json.mapAKeys(toSneakeCase) -json.filterKeys(key.startsWith("_field")) +// traverses all the elements +json.mapAllKeys(toSneakeCase) -json.filterValues(isNotNull) +json.mapAllValues(trim, ifStr) -json.reduce(plus, ifInt) +json.filterAllKeys(key.startsWith("_field")) + +json.filterAllValues(isNotNull) + +json.reduceAll(plus, ifInt) //RFC 6901 json.set(path("/a/b"), value) @@ -171,7 +178,7 @@ Add the following dependency to your building tool: com.github.imrafaelmerino json-values - 9.0.0-RC3 + 9.0.0 ``` diff --git a/pom.xml b/pom.xml index ecde914e..e6e8d684 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.imrafaelmerino json-values jar - 9.0.0-RC3 + 9.0.0 json-values json-values is a functional Java library to work with immutable jsons using persistent data structures. https://github.com/imrafaelmerino/json-values @@ -40,7 +40,6 @@ 1.6.8 3.2.0 2.22.0 - 0.1 1.9.7 0.10.3 2.9.5 @@ -58,10 +57,11 @@ ${DSL-JSON.VERSION} + - com.github.imrafaelmerino - mydsl-json - ${MY-DSL-JSON.VERSION} + com.dslplatform + dsl-json-java8 + 1.9.3 @@ -70,8 +70,6 @@ ${JACKSON-VERSION} - - org.junit.jupiter junit-jupiter-api diff --git a/src/main/java/com/dslplatform/json/MyDslJson.java b/src/main/java/com/dslplatform/json/MyDslJson.java index e0b1c4c6..fd71e45a 100644 --- a/src/main/java/com/dslplatform/json/MyDslJson.java +++ b/src/main/java/com/dslplatform/json/MyDslJson.java @@ -150,7 +150,7 @@ public String toPrettyString(final Json json) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); INSTANCE.serialize(json, - new MyPrettifyOutputStream(baos) + new PrettifyOutputStream(baos) ); return baos.toString(StandardCharsets.UTF_8.name()); } catch (IOException e) { diff --git a/src/main/java/com/dslplatform/json/parsers/JsDecimalParser.java b/src/main/java/com/dslplatform/json/parsers/JsDecimalParser.java index 9b08bdbf..bc2c6ec0 100644 --- a/src/main/java/com/dslplatform/json/parsers/JsDecimalParser.java +++ b/src/main/java/com/dslplatform/json/parsers/JsDecimalParser.java @@ -1,7 +1,7 @@ package com.dslplatform.json.parsers; import com.dslplatform.json.JsonReader; -import com.dslplatform.json.MyNumberConverter; +import com.dslplatform.json.NumberConverter; import jsonvalues.JsBigDec; import jsonvalues.spec.Error; @@ -14,9 +14,9 @@ final class JsDecimalParser extends AbstractParser { @Override - JsBigDec value(final JsonReader reader){ + JsBigDec value(final JsonReader reader) { try { - return JsBigDec.of(MyNumberConverter.parseDecimal(reader)); + return JsBigDec.of(NumberConverter.deserializeDecimal(reader)); } catch (IOException e) { throw new JsParserException(e.getMessage()); } @@ -24,9 +24,9 @@ JsBigDec value(final JsonReader reader){ JsBigDec valueSuchThat(final JsonReader reader, final Function> fn - ){ + ) { try { - final BigDecimal value = MyNumberConverter.parseDecimal(reader); + final BigDecimal value = NumberConverter.deserializeDecimal(reader); final Optional result = fn.apply(value); if (!result.isPresent()) return JsBigDec.of(value); throw reader.newParseError(result.toString()); diff --git a/src/main/java/com/dslplatform/json/parsers/JsIntParser.java b/src/main/java/com/dslplatform/json/parsers/JsIntParser.java index 47bf1fa2..f8c359d4 100644 --- a/src/main/java/com/dslplatform/json/parsers/JsIntParser.java +++ b/src/main/java/com/dslplatform/json/parsers/JsIntParser.java @@ -1,11 +1,12 @@ package com.dslplatform.json.parsers; import com.dslplatform.json.JsonReader; -import com.dslplatform.json.MyNumberConverter; +import com.dslplatform.json.NumberConverter; import com.dslplatform.json.ParsingException; import jsonvalues.JsInt; import jsonvalues.spec.Error; +import java.io.IOException; import java.util.Optional; import java.util.function.IntFunction; @@ -13,8 +14,8 @@ final class JsIntParser extends AbstractParser { @Override JsInt value(final JsonReader reader){ try { - return JsInt.of(MyNumberConverter.parseInt(reader)); - } catch (ParsingException e) { + return JsInt.of(NumberConverter.deserializeInt(reader)); + } catch (IOException e) { throw new JsParserException(e.getMessage()); } } @@ -23,11 +24,11 @@ JsInt valueSuchThat(final JsonReader reader, final IntFunction> fn ){ try { - final int value = MyNumberConverter.parseInt(reader); + final int value = NumberConverter.deserializeInt(reader); final Optional result = fn.apply(value); if (!result.isPresent()) return JsInt.of(value); throw reader.newParseError(result.toString()); - } catch (ParsingException e) { + } catch (IOException e) { throw new JsParserException(e.getMessage()); } diff --git a/src/main/java/com/dslplatform/json/parsers/JsIntegralParser.java b/src/main/java/com/dslplatform/json/parsers/JsIntegralParser.java index 93ef6fd7..6490a7a4 100644 --- a/src/main/java/com/dslplatform/json/parsers/JsIntegralParser.java +++ b/src/main/java/com/dslplatform/json/parsers/JsIntegralParser.java @@ -1,7 +1,7 @@ package com.dslplatform.json.parsers; import com.dslplatform.json.JsonReader; -import com.dslplatform.json.MyNumberConverter; +import com.dslplatform.json.NumberConverter; import jsonvalues.JsBigInt; import jsonvalues.spec.Error; @@ -12,11 +12,11 @@ final class JsIntegralParser extends AbstractParser { @Override - JsBigInt value(final JsonReader reader){ + JsBigInt value(final JsonReader reader) { try { - return JsBigInt.of(MyNumberConverter.parseDecimal(reader) - .toBigIntegerExact()); + return JsBigInt.of(NumberConverter.deserializeDecimal(reader) + .toBigIntegerExact()); } catch (ArithmeticException | IOException e) { throw new JsParserException(reader.newParseError("Integral number expected")); @@ -25,10 +25,10 @@ JsBigInt value(final JsonReader reader){ JsBigInt valueSuchThat(final JsonReader reader, final Function> fn - ){ + ) { try { - final BigInteger value = MyNumberConverter.parseDecimal(reader) - .toBigIntegerExact(); + final BigInteger value = NumberConverter.deserializeDecimal(reader) + .toBigIntegerExact(); final Optional result = fn.apply(value); if (!result.isPresent()) return JsBigInt.of(value); throw reader.newParseError(result.toString()); diff --git a/src/main/java/com/dslplatform/json/parsers/JsLongParser.java b/src/main/java/com/dslplatform/json/parsers/JsLongParser.java index 18ca976a..fcf9580d 100644 --- a/src/main/java/com/dslplatform/json/parsers/JsLongParser.java +++ b/src/main/java/com/dslplatform/json/parsers/JsLongParser.java @@ -1,7 +1,7 @@ package com.dslplatform.json.parsers; import com.dslplatform.json.JsonReader; -import com.dslplatform.json.MyNumberConverter; +import com.dslplatform.json.NumberConverter; import jsonvalues.JsLong; import jsonvalues.spec.Error; @@ -12,9 +12,9 @@ final class JsLongParser extends AbstractParser { @Override - JsLong value(final JsonReader reader){ + JsLong value(final JsonReader reader) { try { - return JsLong.of(MyNumberConverter.parseLong(reader)); + return JsLong.of(NumberConverter.deserializeLong(reader)); } catch (IOException e) { throw new JsParserException(e.getMessage()); } @@ -22,9 +22,9 @@ JsLong value(final JsonReader reader){ JsLong valueSuchThat(final JsonReader reader, final LongFunction> fn - ){ + ) { try { - final long value = MyNumberConverter.parseLong(reader); + final long value = NumberConverter.deserializeLong(reader); final Optional result = fn.apply(value); if (!result.isPresent()) return JsLong.of(value); throw reader.newParseError(result.toString()); diff --git a/src/test/java/jsonvalues/TestJsParser.java b/src/test/java/jsonvalues/TestJsParser.java index 1b6f2765..0e678e18 100644 --- a/src/test/java/jsonvalues/TestJsParser.java +++ b/src/test/java/jsonvalues/TestJsParser.java @@ -48,7 +48,7 @@ public void test_parse_string_into_obj() throws IOException { final JsObj example = JsObj.of("a", - JsStr.of("a"), + JsStr.of("001"), "b", JsInt.of(10), "c", @@ -73,8 +73,7 @@ public void test_parse_string_into_obj() throws IOException { )) ); - final JsObj parsed = parser.parse(example - .toString()); + final JsObj parsed = parser.parse(example.toString()); Assertions.assertEquals(parsed, example