generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support unwrapping arrays for
JsonNode
decoder (#747)
* Support unwrapping arrays for `JsonNode` decoder * Add since * Remove unneeded methods * Update serde-oracle-jdbc-json/src/main/java/io/micronaut/serde/oracle/jdbc/json/AbstractOracleJdbcJsonObjectMapper.java Co-authored-by: Jonas Konrad <jonas.konrad@oracle.com> --------- Co-authored-by: Jonas Konrad <jonas.konrad@oracle.com>
- Loading branch information
Showing
7 changed files
with
300 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
serde-jsonp/src/test/groovy/io/micronaut/serde/json/stream/nodes/RootConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package io.micronaut.serde.json.stream.nodes; | ||
|
||
import io.micronaut.context.annotation.ConfigurationProperties; | ||
import io.micronaut.core.convert.format.MapFormat; | ||
import io.micronaut.core.naming.conventions.StringConvention; | ||
import io.micronaut.serde.annotation.Serdeable; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@ConfigurationProperties("example.root.config") | ||
@Serdeable | ||
public class RootConfig { | ||
private String someValue; | ||
private NestedConfig someNested = new NestedConfig(); | ||
private List<NestedListConfig> someListNested = List.of(); | ||
@MapFormat(keyFormat = StringConvention.RAW) | ||
private Map<String, RawNestedConfig> someRawNested = Map.of(); | ||
|
||
public String getSomeValue() { | ||
return someValue; | ||
} | ||
|
||
public void setSomeValue(String someValue) { | ||
this.someValue = someValue; | ||
} | ||
|
||
public NestedConfig getSomeNested() { | ||
return someNested; | ||
} | ||
|
||
public void setSomeNested(NestedConfig someNested) { | ||
this.someNested = someNested; | ||
} | ||
|
||
public List<NestedListConfig> getSomeListNested() { | ||
return someListNested; | ||
} | ||
|
||
public void setSomeListNested(List<NestedListConfig> someListNested) { | ||
this.someListNested = someListNested; | ||
} | ||
|
||
public Map<String, RawNestedConfig> getSomeRawNested() { | ||
return someRawNested; | ||
} | ||
|
||
public void setSomeRawNested(Map<String, RawNestedConfig> someRawNested) { | ||
this.someRawNested = someRawNested; | ||
} | ||
|
||
@Serdeable | ||
@ConfigurationProperties("some-nested") | ||
public static class NestedConfig { | ||
private String nestedValue; | ||
|
||
public String getNestedValue() { | ||
return nestedValue; | ||
} | ||
|
||
public void setNestedValue(String nestedValue) { | ||
this.nestedValue = nestedValue; | ||
} | ||
} | ||
|
||
@Serdeable | ||
public static class NestedListConfig { | ||
private String nestedListValue; | ||
|
||
public String getNestedListValue() { | ||
return nestedListValue; | ||
} | ||
|
||
public void setNestedListValue(String nestedListValue) { | ||
this.nestedListValue = nestedListValue; | ||
} | ||
} | ||
|
||
@Serdeable | ||
public static class RawNestedConfig { | ||
private String rawNestedValue; | ||
|
||
public String getRawNestedValue() { | ||
return rawNestedValue; | ||
} | ||
|
||
public void setRawNestedValue(String rawNestedValue) { | ||
this.rawNestedValue = rawNestedValue; | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
serde-jsonp/src/test/groovy/io/micronaut/serde/json/stream/nodes/RootConfigSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.micronaut.serde.json.stream.nodes | ||
|
||
import io.micronaut.test.extensions.spock.annotation.MicronautTest | ||
import jakarta.inject.Inject | ||
import spock.lang.Specification | ||
|
||
@MicronautTest | ||
class RootConfigSpec extends Specification { | ||
|
||
@Inject | ||
RootConfig rootConfig | ||
|
||
void "test config injection"() { | ||
expect: | ||
rootConfig.someValue == "foo" | ||
rootConfig.someNested | ||
rootConfig.someNested.nestedValue == "bar" | ||
rootConfig.someListNested | ||
rootConfig.someListNested.size() == 2 | ||
rootConfig.someListNested[0].nestedListValue == "baz1" | ||
rootConfig.someListNested[1].nestedListValue == "baz2" | ||
rootConfig.someRawNested | ||
rootConfig.someRawNested.size() == 2 | ||
rootConfig.someRawNested.get('abc_def').rawNestedValue == "abc123" | ||
rootConfig.someRawNested.get('def_ghi').rawNestedValue == "def456" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
example: | ||
root: | ||
config: | ||
some-value: "foo" | ||
some-nested: | ||
nested-value: "bar" | ||
some-list-nested: | ||
- nestedListValue: "baz1" | ||
- nestedListValue: "baz2" | ||
some-raw-nested: | ||
abc_def: | ||
raw-nested-value: "abc123" | ||
def_ghi: | ||
raw-nested-value: "def456" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.