Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public String jsonString() {
@Override
public <T> T read(String path, Predicate... filters) {
notEmpty(path, "path can not be null or empty");
return read(pathFromCache(path, filters));
return read(pathFromCache(path.trim(), filters));
}

@Override
Expand Down
20 changes: 20 additions & 0 deletions json-path/src/test/java/com/jayway/jsonpath/Issue_1001.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.jayway.jsonpath;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class Issue_1001 {
@Test
public void testTrailingNewlineInPath() {
String context = "{\n" +
" \"level_0\": {\n" +
" \"level_1\": {\n" +
" \"level_2\": \"At level 2\"\n" +
" }\n" +
" }\n" +
"}";
String result = JsonPath.read(context, "$.level_0.level_1.level_2\n");
assertThat(result).isEqualTo("At level 2");
}
}