LANG-1374: fix logic in isJsonArray method of JsonToStringStyle
This commit is contained in:
parent
f5a9effebd
commit
c614fbcc79
|
@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
<body>
|
||||
|
||||
<release version="3.8" date="2017-MM-DD" description="New features and bug fixes. Requires Java 7, supports Java 8, 9, 10.">
|
||||
<action issue="LANG-1374" type="fix" dev="kinow" due-to="Jaswanth Bala">Parsing Json Array failed</action>
|
||||
<action issue="LANG-1371" type="fix" dev="pschumacher" due-to="Dmitry Ovchinnikov">Fix TypeUtils#parameterize to work correctly with narrower-typed array</action>
|
||||
<action issue="LANG-1370" type="fix" dev="kinow" due-to="Andre Dieb">Fix EventCountCircuitBreaker increment batch</action>
|
||||
<action issue="LANG-1367" type="update" dev="ggregory" due-to="Gary Gregory">ObjectUtils.identityToString(Object) and friends should allocate builders and buffers with a size</action>
|
||||
|
|
|
@ -2591,7 +2591,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
|
||||
private boolean isJsonArray(final String valueAsString) {
|
||||
return valueAsString.startsWith(getArrayStart())
|
||||
&& valueAsString.startsWith(getArrayEnd());
|
||||
&& valueAsString.endsWith(getArrayEnd());
|
||||
}
|
||||
|
||||
private boolean isJsonObject(final String valueAsString) {
|
||||
|
|
|
@ -358,6 +358,26 @@ public class JsonToStringStyleTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArray() {
|
||||
final Person p = new Person();
|
||||
p.name = "Jane Doe";
|
||||
p.age = 25;
|
||||
p.smoker = true;
|
||||
|
||||
assertEquals(
|
||||
"{\"name\":\"Jane Doe\",\"age\":25,\"smoker\":true,\"groups\":['admin', 'manager', 'user']}",
|
||||
new ToStringBuilder(p).append("name", p.name)
|
||||
.append("age", p.age).append("smoker", p.smoker)
|
||||
.append("groups", new Object() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "['admin', 'manager', 'user']";
|
||||
}
|
||||
})
|
||||
.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* An object with nested object structures used to test {@link ToStringStyle.JsonToStringStyle}.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue