Commit c97a9a0c authored by Stephane Nicoll's avatar Stephane Nicoll

Merge branch '1.5.x'

parents 2be0c465 2f6d05dc
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -31,6 +31,7 @@ import org.springframework.util.StringUtils;
*
* @author Dave Syer
* @author Jean de Klerk
* @author Stephane Nicoll
* @since 1.2.0
* @see JsonParserFactory
*/
......@@ -112,12 +113,7 @@ public class BasicJsonParser implements JsonParser {
for (String pair : tokenize(json)) {
String[] values = StringUtils.trimArrayElements(StringUtils.split(pair, ":"));
String key = trimLeadingCharacter(trimTrailingCharacter(values[0], '"'), '"');
Object value = null;
if (values.length > 0) {
String string = trimLeadingCharacter(
trimTrailingCharacter(values[1], '"'), '"');
value = parseInternal(string);
}
Object value = parseInternal(values[1]);
map.put(key, value);
}
return map;
......
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -56,6 +56,13 @@ public abstract class AbstractJsonParserTests {
assertThat(map.get("spam")).isEqualTo(1.23d);
}
@Test
public void stringContainingNumber() {
Map<String, Object> map = this.parser.parseMap("{\"foo\":\"123\"}");
assertThat(map).hasSize(1);
assertThat(map.get("foo")).isEqualTo("123");
}
@Test
public void emptyMap() {
Map<String, Object> map = this.parser.parseMap("{}");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment