Skip to content

Commit

Permalink
Remove my dsljson (#164)
Browse files Browse the repository at this point in the history
* refactor: 💡 remove mydsl-json dependency

* ci: 🎡 9.0.0 version
  • Loading branch information
imrafaelmerino committed Jan 30, 2021
1 parent e35646c commit 0617ccf
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 44 deletions.
9 changes: 5 additions & 4 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))



Expand Down
21 changes: 14 additions & 7 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -171,7 +178,7 @@ Add the following dependency to your building tool:
<dependency>
<groupId>com.github.imrafaelmerino</groupId>
<artifactId>json-values</artifactId>
<version>9.0.0-RC3</version>
<version>9.0.0</version>
</dependency>
```

Expand Down
12 changes: 5 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.github.imrafaelmerino</groupId>
<artifactId>json-values</artifactId>
<packaging>jar</packaging>
<version>9.0.0-RC3</version>
<version>9.0.0</version>
<name>json-values</name>
<description>json-values is a functional Java library to work with immutable jsons using persistent data structures.</description>
<url>https://github.com/imrafaelmerino/json-values</url>
Expand Down Expand Up @@ -40,7 +40,6 @@
<NEXUS-STAGING-MAVEN-PLUGIN.VERSION>1.6.8</NEXUS-STAGING-MAVEN-PLUGIN.VERSION>
<MAVEN-JAVADOC-PLUGIN.VERSION>3.2.0</MAVEN-JAVADOC-PLUGIN.VERSION>
<MAVEN-SUREFIRE-PLUGIN.VERSION>2.22.0</MAVEN-SUREFIRE-PLUGIN.VERSION>
<MY-DSL-JSON.VERSION>0.1</MY-DSL-JSON.VERSION>
<DSL-JSON.VERSION>1.9.7</DSL-JSON.VERSION>
<VAVR.VERSION>0.10.3</VAVR.VERSION>
<JACKSON-DATAFORMAT-YAML.VERSION>2.9.5</JACKSON-DATAFORMAT-YAML.VERSION>
Expand All @@ -58,10 +57,11 @@
<version>${DSL-JSON.VERSION}</version>
</dependency>


<dependency>
<groupId>com.github.imrafaelmerino</groupId>
<artifactId>mydsl-json</artifactId>
<version>${MY-DSL-JSON.VERSION}</version>
<groupId>com.dslplatform</groupId>
<artifactId>dsl-json-java8</artifactId>
<version>1.9.3</version>
</dependency>

<dependency>
Expand All @@ -70,8 +70,6 @@
<version>${JACKSON-VERSION}</version>
</dependency>



<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/dslplatform/json/MyDslJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/dslplatform/json/parsers/JsDecimalParser.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -14,19 +14,19 @@
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());
}
}

JsBigDec valueSuchThat(final JsonReader<?> reader,
final Function<BigDecimal, Optional<Error>> fn
){
) {
try {
final BigDecimal value = MyNumberConverter.parseDecimal(reader);
final BigDecimal value = NumberConverter.deserializeDecimal(reader);
final Optional<Error> result = fn.apply(value);
if (!result.isPresent()) return JsBigDec.of(value);
throw reader.newParseError(result.toString());
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/dslplatform/json/parsers/JsIntParser.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
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;

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());
}
}
Expand All @@ -23,11 +24,11 @@ JsInt valueSuchThat(final JsonReader<?> reader,
final IntFunction<Optional<Error>> fn
){
try {
final int value = MyNumberConverter.parseInt(reader);
final int value = NumberConverter.deserializeInt(reader);
final Optional<Error> 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());

}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/dslplatform/json/parsers/JsIntegralParser.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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"));
Expand All @@ -25,10 +25,10 @@ JsBigInt value(final JsonReader<?> reader){

JsBigInt valueSuchThat(final JsonReader<?> reader,
final Function<BigInteger, Optional<Error>> fn
){
) {
try {
final BigInteger value = MyNumberConverter.parseDecimal(reader)
.toBigIntegerExact();
final BigInteger value = NumberConverter.deserializeDecimal(reader)
.toBigIntegerExact();
final Optional<Error> result = fn.apply(value);
if (!result.isPresent()) return JsBigInt.of(value);
throw reader.newParseError(result.toString());
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/dslplatform/json/parsers/JsLongParser.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -12,19 +12,19 @@
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());
}
}

JsLong valueSuchThat(final JsonReader<?> reader,
final LongFunction<Optional<Error>> fn
){
) {
try {
final long value = MyNumberConverter.parseLong(reader);
final long value = NumberConverter.deserializeLong(reader);
final Optional<Error> result = fn.apply(value);
if (!result.isPresent()) return JsLong.of(value);
throw reader.newParseError(result.toString());
Expand Down
5 changes: 2 additions & 3 deletions src/test/java/jsonvalues/TestJsParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit 0617ccf

Please sign in to comment.