Skip to content

Commit 9cf6131

Browse files
committed
Add unit test for U.fromJsonMap(json) and U.get(map, path).
1 parent f611f34 commit 9cf6131

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/test/java/com/github/underscore/lodash/LodashTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,26 @@ public void stackoverflow5() {
10411041
assertEquals("{getRolesRequest={Type=ABC}}", jsonData.toString());
10421042
}
10431043

1044+
@Test
1045+
public void stackoverflow6() {
1046+
// https://stackoverflow.com/questions/59585708/getting-null-pointer-while-reading-the-fileds-from-json-to-pojo
1047+
String jsonData = "{\n"
1048+
+ " \"TEST\": {\n"
1049+
+ " \"NAME\": \"PART_TRAN\",\n"
1050+
+ " \"VERSION\": \"9.0\",\n"
1051+
+ " \"ID\": \"----\",\n"
1052+
+ " \"SEGMENT\": {\n"
1053+
+ " \"TYPE\": \"R\",\n"
1054+
+ " \"CLIENT_ID\": \"----\",\n"
1055+
+ " \"UN_NUM\": \"UN\"\n"
1056+
+ " }"
1057+
+ " }"
1058+
+ "}";
1059+
Map<String, Object> jsonObject = U.fromJsonMap(jsonData);
1060+
assertEquals("R", U.<String>get(jsonObject, "TEST.SEGMENT.TYPE"));
1061+
assertEquals("UN", U.<String>get(jsonObject, "TEST.SEGMENT.UN_NUM"));
1062+
}
1063+
10441064
@SuppressWarnings("unchecked")
10451065
@Test
10461066
public void sqlru1() {

0 commit comments

Comments
 (0)