Browse Source

Fixed backward compatibility in JsonModel.

pull/8/merge
Kalle Stenflo 13 years ago
parent
commit
fb9cc8dfe2
  1. 1
      json-path/pom.xml
  2. 12
      json-path/src/main/java/com/jayway/jsonpath/JsonModel.java
  3. 6
      json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java
  4. 3
      pom.xml

1
json-path/pom.xml

@ -69,6 +69,7 @@
<plugin> <plugin>
<groupId>org.apache.felix</groupId> <groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId> <artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions> <extensions>true</extensions>
</plugin> </plugin>
</plugins> </plugins>

12
json-path/src/main/java/com/jayway/jsonpath/JsonModel.java

@ -488,6 +488,9 @@ public class JsonModel {
return new JsonModel(json, JsonProviderFactory.createProvider()); return new JsonModel(json, JsonProviderFactory.createProvider());
} }
public static JsonModel create(String json) {
return model(json);
}
/** /**
* Creates a JsonModel * Creates a JsonModel
@ -500,6 +503,9 @@ public class JsonModel {
return new JsonModel(jsonObject, JsonProviderFactory.createProvider()); return new JsonModel(jsonObject, JsonProviderFactory.createProvider());
} }
public static JsonModel create(Object jsonObject) {
return model(jsonObject);
}
/** /**
* Creates a JsonModel * Creates a JsonModel
@ -512,6 +518,9 @@ public class JsonModel {
return new JsonModel(url, JsonProviderFactory.createProvider()); return new JsonModel(url, JsonProviderFactory.createProvider());
} }
public static JsonModel create(URL url) throws IOException {
return model(url);
}
/** /**
* Creates a JsonModel * Creates a JsonModel
@ -524,6 +533,9 @@ public class JsonModel {
return new JsonModel(jsonInputStream, JsonProviderFactory.createProvider()); return new JsonModel(jsonInputStream, JsonProviderFactory.createProvider());
} }
public static JsonModel create(InputStream jsonInputStream) throws IOException {
return model(jsonInputStream);
}
// -------------------------------------------------------- // --------------------------------------------------------
// //

6
json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java

@ -24,4 +24,10 @@ public class IssuesTest {
assertNull(JsonPath.read(json, "$.foo.id")); assertNull(JsonPath.read(json, "$.foo.id"));
} }
@Test
public void issue_11() throws Exception {
//String json = "{ \"foo\" : [] }";
//JsonPath.read(json, "$.foo[?(@.rel= 'item')][0].uri");
}
} }

3
pom.xml

@ -14,7 +14,8 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.sonatype.oss</groupId> <groupId>org.sonatype.oss</groupId>

Loading…
Cancel
Save