LANG-1374: fix logic in isJsonArray method of JsonToStringStyle

This commit is contained in:
Bruno P. Kinoshita 2018-01-04 22:15:08 +13:00
parent f5a9effebd
commit c614fbcc79
3 changed files with 22 additions and 1 deletions

View File

@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
<body> <body>
<release version="3.8" date="2017-MM-DD" description="New features and bug fixes. Requires Java 7, supports Java 8, 9, 10."> <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-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-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> <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>

View File

@ -2591,7 +2591,7 @@ public abstract class ToStringStyle implements Serializable {
private boolean isJsonArray(final String valueAsString) { private boolean isJsonArray(final String valueAsString) {
return valueAsString.startsWith(getArrayStart()) return valueAsString.startsWith(getArrayStart())
&& valueAsString.startsWith(getArrayEnd()); && valueAsString.endsWith(getArrayEnd());
} }
private boolean isJsonObject(final String valueAsString) { private boolean isJsonObject(final String valueAsString) {

View File

@ -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}. * An object with nested object structures used to test {@link ToStringStyle.JsonToStringStyle}.
* *