Skip to content

Commit e9117db

Browse files
authored
Merge branch 'master' into patch-2
2 parents de745e9 + 7a85b51 commit e9117db

9 files changed

Lines changed: 113 additions & 22 deletions

File tree

.github/workflows/deployment.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# For more information see:
2+
# * https://docs.github.com/en/actions/learn-github-actions
3+
# * https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
4+
# * https://github.com/actions/setup-java/blob/v3.13.0/docs/advanced-usage.md#Publishing-using-Apache-Maven
5+
#
6+
7+
name: Deployment workflow
8+
9+
on:
10+
release:
11+
types: [published]
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Java for publishing to Maven Central Repository
22+
uses: actions/setup-java@v3
23+
with:
24+
# Use lowest supported LTS Java version
25+
java-version: '8'
26+
distribution: 'temurin'
27+
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
28+
server-username: MAVEN_USERNAME # env variable for username in deploy
29+
server-password: MAVEN_PASSWORD # env variable for token in deploy
30+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
31+
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
32+
33+
- name: Publish to the Maven Central Repository
34+
run: mvn --batch-mode deploy
35+
env:
36+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
37+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
38+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
39+
# - name: Set up Java for publishing to GitHub Packages
40+
# uses: actions/setup-java@v3
41+
# with:
42+
# # Use lowest supported LTS Java version
43+
# java-version: '8'
44+
# distribution: 'temurin'
45+
# - name: Publish to GitHub Packages
46+
# run: mvn --batch-mode deploy
47+
# env:
48+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pipeline.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This workflow will build a Java project with Maven
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
2+
# For more information see: https://docs.github.com/en/actions/learn-github-actions or https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
33

44
name: Java CI with Maven
55

@@ -37,13 +37,21 @@ jobs:
3737
mvn site -DgenerateReports=false -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.target=${{ matrix.java }}
3838
- name: Upload Test Results ${{ matrix.java }}
3939
if: ${{ always() }}
40-
uses: actions/upload-artifact@v1
40+
uses: actions/upload-artifact@v3
4141
with:
4242
name: Test Results ${{ matrix.java }}
4343
path: target/surefire-reports/
4444
- name: Upload Test Report ${{ matrix.java }}
4545
if: ${{ always() }}
46-
uses: actions/upload-artifact@v1
46+
uses: actions/upload-artifact@v3
4747
with:
4848
name: Test Report ${{ matrix.java }}
4949
path: target/site/
50+
- name: Package Jar ${{ matrix.java }}
51+
run: mvn clean package -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.target=${{ matrix.java }} -Dmaven.test.skip=true -Dmaven.site.skip=true
52+
- name: Upload Package Results ${{ matrix.java }}
53+
if: ${{ always() }}
54+
uses: actions/upload-artifact@v3
55+
with:
56+
name: Package Jar ${{ matrix.java }}
57+
path: target/*.jar

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# ignore eclipse project files
22
.project
33
.classpath
4+
# ignore vscode files
5+
.vscode
46
# ignore Intellij Idea project files
57
.idea
68
*.iml

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ JSON in Java [package org.json]
77
===============================
88

99
[![Maven Central](https://img.shields.io/maven-central/v/org.json/json.svg)](https://mvnrepository.com/artifact/org.json/json)
10+
[![Java CI with Maven](https://github.com/stleary/JSON-java/actions/workflows/pipeline.yml/badge.svg)](https://github.com/stleary/JSON-java/actions/workflows/pipeline.yml)
11+
[![CodeQL](https://github.com/stleary/JSON-java/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/stleary/JSON-java/actions/workflows/codeql-analysis.yml)
1012

1113
**[Click here if you just want the latest release jar file.](https://search.maven.org/remotecontent?filepath=org/json/json/20231013/json-20231013.jar)**
1214

@@ -26,6 +28,7 @@ Project goals include:
2628
* Maintain backward compatibility
2729
* Designed and tested to use on Java versions 1.8 - 21
2830

31+
2932
The files in this package implement JSON encoders and decoders. The package can also convert between JSON and XML, HTTP headers, Cookies, and CDL.
3033

3134
# If you would like to contribute to this project

pom.xml

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
</description>
2222
<url>https://github.com/douglascrockford/JSON-java</url>
2323

24-
<parent>
25-
<groupId>org.sonatype.oss</groupId>
26-
<artifactId>oss-parent</artifactId>
27-
<version>9</version>
28-
</parent>
29-
3024
<scm>
3125
<url>https://github.com/douglascrockford/JSON-java.git</url>
3226
<connection>scm:git:git://github.com/douglascrockford/JSON-java.git</connection>
@@ -53,6 +47,19 @@
5347
</properties>
5448

5549

50+
<distributionManagement>
51+
<repository>
52+
<id>ossrh</id>
53+
<name>Central Repository OSSRH</name>
54+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
55+
</repository>
56+
<snapshotRepository>
57+
<id>ossrh</id>
58+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
59+
</snapshotRepository>
60+
</distributionManagement>
61+
62+
5663
<dependencies>
5764
<dependency>
5865
<groupId>junit</groupId>
@@ -159,17 +166,34 @@
159166
<autoReleaseAfterClose>false</autoReleaseAfterClose>
160167
</configuration>
161168
</plugin>
169+
<plugin>
170+
<groupId>org.moditect</groupId>
171+
<artifactId>moditect-maven-plugin</artifactId>
172+
<version>1.0.0.Final</version>
173+
<executions>
174+
<execution>
175+
<id>add-module-infos</id>
176+
<phase>package</phase>
177+
<goals>
178+
<goal>add-module-info</goal>
179+
</goals>
180+
<configuration>
181+
<jvmVersion>9</jvmVersion>
182+
<module>
183+
<moduleInfoSource>
184+
module org.json {
185+
exports org.json;
186+
}
187+
</moduleInfoSource>
188+
</module>
189+
</configuration>
190+
</execution>
191+
</executions>
192+
</plugin>
162193
<plugin>
163194
<groupId>org.apache.maven.plugins</groupId>
164195
<artifactId>maven-jar-plugin</artifactId>
165196
<version>3.3.0</version>
166-
<configuration>
167-
<archive>
168-
<manifestEntries>
169-
<Automatic-Module-Name>org.json</Automatic-Module-Name>
170-
</manifestEntries>
171-
</archive>
172-
</configuration>
173197
</plugin>
174198
</plugins>
175199
</build>

src/main/java/org/json/ParserConfiguration.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public boolean isKeepStrings() {
7171
*
7272
* @param newVal
7373
* new value to use for the <code>keepStrings</code> configuration option.
74-
*
74+
* @param <T> the type of the configuration object
75+
*
7576
* @return The existing configuration will not be modified. A new configuration is returned.
7677
*/
7778
public <T extends ParserConfiguration> T withKeepStrings(final boolean newVal) {
@@ -96,6 +97,8 @@ public int getMaxNestingDepth() {
9697
* Using any negative value as a parameter is equivalent to setting no limit to the nesting depth,
9798
* which means the parses will go as deep as the maximum call stack size allows.
9899
* @param maxNestingDepth the maximum nesting depth allowed to the XML parser
100+
* @param <T> the type of the configuration object
101+
*
99102
* @return The existing configuration will not be modified. A new configuration is returned.
100103
*/
101104
public <T extends ParserConfiguration> T withMaxNestingDepth(int maxNestingDepth) {

src/test/java/org/json/junit/JSONMLTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,8 @@ public void testToJSONObject_reversibility() {
762762
final String xml = JSONML.toString(originalObject);
763763
final JSONObject revertedObject = JSONML.toJSONObject(xml, false);
764764
final String newJson = revertedObject.toString();
765-
assertTrue("JSON Objects are not similar",originalObject.similar(revertedObject));
766-
assertEquals("original JSON does not equal the new JSON",originalJson, newJson);
765+
assertTrue("JSON Objects are not similar", originalObject.similar(revertedObject));
766+
assertTrue("JSON Strings are not similar", new JSONObject(originalJson).similar(new JSONObject(newJson)));
767767
}
768768

769769
// these tests do not pass for the following reasons:

src/test/java/org/json/junit/JSONObjectTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,9 @@ public void valueToString() {
20952095
"}";
20962096
JSONObject jsonObject = new JSONObject(jsonObjectStr);
20972097
assertTrue("jsonObject valueToString() incorrect",
2098-
JSONObject.valueToString(jsonObject).equals(jsonObject.toString()));
2098+
new JSONObject(JSONObject.valueToString(jsonObject))
2099+
.similar(new JSONObject(jsonObject.toString()))
2100+
);
20992101
String jsonArrayStr =
21002102
"[1,2,3]";
21012103
JSONArray jsonArray = new JSONArray(jsonArrayStr);
@@ -2106,7 +2108,8 @@ public void valueToString() {
21062108
map.put("key2", "val2");
21072109
map.put("key3", "val3");
21082110
assertTrue("map valueToString() incorrect",
2109-
jsonObject.toString().equals(JSONObject.valueToString(map)));
2111+
new JSONObject(jsonObject.toString())
2112+
.similar(new JSONObject(JSONObject.valueToString(map))));
21102113
Collection<Integer> collection = new ArrayList<Integer>();
21112114
collection.add(Integer.valueOf(1));
21122115
collection.add(Integer.valueOf(2));

src/test/java/org/json/junit/XMLTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ public void testIndentComplicatedJsonObjectWithArrayAndWithConfig(){
12341234
for (int numRead; (numRead = in.read(buffer, 0, buffer.length)) > 0; ) {
12351235
expected.append(buffer, 0, numRead);
12361236
}
1237-
assertEquals(expected.toString(), actualString);
1237+
assertTrue(XML.toJSONObject(expected.toString()).similar(XML.toJSONObject(actualString)));
12381238
}
12391239
} catch (IOException e) {
12401240
fail("file writer error: " +e.getMessage());

0 commit comments

Comments
 (0)