Skip to content

Commit 06e8a23

Browse files
committed
add a function and update readme
1 parent 15cf3ad commit 06e8a23

File tree

5 files changed

+614
-3
lines changed

5 files changed

+614
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
.idea
88
*.iml
99
/target/
10+
/src/test/resources/xml_files
1011

1112
/bin/
1213
build

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Bug fixes, code improvements, and unit test coverage changes are welcome! Becaus
4040
# Build Instructions
4141

4242
The org.json package can be built from the command line, Maven, and Gradle. The unit tests can be executed from Maven, Gradle, or individually in an IDE e.g. Eclipse.
43-
43+
4444
**Building from the command line**
4545

4646
*Build the class files from the package root directory src/main/java*
@@ -83,7 +83,7 @@ java -cp .:json-java.jar Test (Unix Systems)
8383
{"abc":"def"}
8484
```
8585

86-
86+
8787
**Tools to build the package and execute the unit tests**
8888

8989
Execute the test suite with Maven:
@@ -109,6 +109,23 @@ gradlew testWithStrictMode
109109
mvn test -P test-strict-mode
110110
```
111111

112+
# Milestone 2
113+
114+
For the Milestone 2 of SWE262P, 2 new functions were added:
115+
116+
```java
117+
static JSONObject toJSONObject(Reader reader, JSONPointer path)
118+
static JSONObject toJSONObject(Reader reader, JSONPointer path, JSONObject replacement)
119+
```
120+
121+
The first one takes in 2 parameters, a `Reader` object which contains some XML input and a `JSONPointer` object that includes a json path for querying, and returns a `JSONObject` object which has the corresponding path, or throw an error if that path does not exist.
122+
123+
The first one takes in 3 parameters, a `Reader` object which contains some XML input and a `JSONPointer` object that includes a json path for querying, and a `JSONObject` for replacement. And returns a new `JSONObject` object which has the corresponding path replaced with the new given object, or throw an error if that path does not exist.
124+
125+
Both new functions are placed in the `XML.java` file.
126+
127+
The test cases of the functions are placed under the `org.json.junit.milestone2.tests` package, and to run the test case which deals with large file input, first create a folder named `xml_files` under the `/src/test/resources` path, and put the xml files for testing under this path.
128+
112129
# Notes
113130

114131
For more information, please see [NOTES.md](https://github.com/stleary/JSON-java/blob/master/docs/NOTES.md)

0 commit comments

Comments
 (0)