diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
deleted file mode 100644
index df4bf79..0000000
--- a/.github/workflows/codeql-analysis.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-name: "CodeQL"
-
-on:
- push:
- branches: [ master ]
- pull_request:
- # The branches below must be a subset of the branches above
- branches: [ master ]
- schedule:
- - cron: '18 18 * * 1'
-
-jobs:
- analyze:
- name: Analyze
- runs-on: ubuntu-latest
- permissions:
- actions: read
- contents: read
- security-events: write
-
- strategy:
- fail-fast: false
- matrix:
- language: [ 'java' ]
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v3
-
- # Initializes the CodeQL tools for scanning.
- - name: Initialize CodeQL
- uses: github/codeql-action/init@v2
- with:
- languages: ${{ matrix.language }}
- # If you wish to specify custom queries, you can do so here or in a config file.
- # By default, queries listed here will override any specified in a config file.
- # Prefix the list here with "+" to use these queries and those in the config file.
- # queries: ./path/to/local/query, your-org/your-repo/queries@main
-
- - run: "mvn clean compile -Dmaven.test.skip=true -Dmaven.site.skip=true -Dmaven.javadoc.skip=true"
-
- - name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml
deleted file mode 100644
index d59702c..0000000
--- a/.github/workflows/pipeline.yml
+++ /dev/null
@@ -1,228 +0,0 @@
-# This workflow will build a Java project with Maven
-# 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
-
-name: Java CI with Maven
-
-on:
- push:
- # branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- # old-school build and jar method. No tests run or compiled.
- build-1_6:
- name: Java 1.6
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - name: Setup java
- uses: actions/setup-java@v1
- with:
- java-version: 1.6
- - name: Compile Java 1.6
- run: |
- mkdir -p target/classes
- javac -version
- javac -source 1.6 -target 1.6 -d target/classes/ src/main/java/org/json/*.java
- - name: Create java 1.6 JAR
- run: |
- jar cvf target/org.json.jar -C target/classes .
- - name: Upload JAR 1.6
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Create java 1.6 JAR
- path: target/*.jar
-
- build-8:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- max-parallel: 1
- matrix:
- # build against supported Java LTS versions:
- java: [ 8 ]
- name: Java ${{ matrix.java }}
- steps:
- - uses: actions/checkout@v3
- - name: Set up JDK ${{ matrix.java }}
- uses: actions/setup-java@v3
- with:
- distribution: 'temurin'
- java-version: ${{ matrix.java }}
- cache: 'maven'
- - name: Compile Java ${{ matrix.java }}
- run: mvn clean compile -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} -D maven.test.skip=true -D maven.site.skip=true -D maven.javadoc.skip=true
- - name: Run Tests ${{ matrix.java }}
- run: |
- mvn test -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
- - name: Build Test Report ${{ matrix.java }}
- if: ${{ always() }}
- run: |
- mvn surefire-report:report-only -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
- mvn site -D generateReports=false -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
- - name: Upload Test Results ${{ matrix.java }}
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Test Results ${{ matrix.java }}
- path: target/surefire-reports/
- - name: Upload Test Report ${{ matrix.java }}
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Test Report ${{ matrix.java }}
- path: target/site/
- - name: Package Jar ${{ matrix.java }}
- run: mvn clean package -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} -D maven.test.skip=true -D maven.site.skip=true
- - name: Upload Package Results ${{ matrix.java }}
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Package Jar ${{ matrix.java }}
- path: target/*.jar
-
- build-11:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- max-parallel: 1
- matrix:
- # build against supported Java LTS versions:
- java: [ 11 ]
- name: Java ${{ matrix.java }}
- steps:
- - uses: actions/checkout@v3
- - name: Set up JDK ${{ matrix.java }}
- uses: actions/setup-java@v3
- with:
- distribution: 'temurin'
- java-version: ${{ matrix.java }}
- cache: 'maven'
- - name: Compile Java ${{ matrix.java }}
- run: mvn clean compile -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} -D maven.test.skip=true -D maven.site.skip=true -D maven.javadoc.skip=true
- - name: Run Tests ${{ matrix.java }}
- run: |
- mvn test -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
- - name: Build Test Report ${{ matrix.java }}
- if: ${{ always() }}
- run: |
- mvn surefire-report:report-only -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
- mvn site -D generateReports=false -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
- - name: Upload Test Results ${{ matrix.java }}
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Test Results ${{ matrix.java }}
- path: target/surefire-reports/
- - name: Upload Test Report ${{ matrix.java }}
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Test Report ${{ matrix.java }}
- path: target/site/
- - name: Package Jar ${{ matrix.java }}
- run: mvn clean package -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} -D maven.test.skip=true -D maven.site.skip=true
- - name: Upload Package Results ${{ matrix.java }}
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Package Jar ${{ matrix.java }}
- path: target/*.jar
-
- build-17:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- max-parallel: 1
- matrix:
- # build against supported Java LTS versions:
- java: [ 17 ]
- name: Java ${{ matrix.java }}
- steps:
- - uses: actions/checkout@v3
- - name: Set up JDK ${{ matrix.java }}
- uses: actions/setup-java@v3
- with:
- distribution: 'temurin'
- java-version: ${{ matrix.java }}
- cache: 'maven'
- - name: Compile Java ${{ matrix.java }}
- run: mvn clean compile -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} -D maven.test.skip=true -D maven.site.skip=true -D maven.javadoc.skip=true
- - name: Run Tests ${{ matrix.java }}
- run: |
- mvn test -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
- - name: Build Test Report ${{ matrix.java }}
- if: ${{ always() }}
- run: |
- mvn surefire-report:report-only -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
- mvn site -D generateReports=false -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
- - name: Upload Test Results ${{ matrix.java }}
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Test Results ${{ matrix.java }}
- path: target/surefire-reports/
- - name: Upload Test Report ${{ matrix.java }}
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Test Report ${{ matrix.java }}
- path: target/site/
- - name: Package Jar ${{ matrix.java }}
- run: mvn clean package -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} -D maven.test.skip=true -D maven.site.skip=true
- - name: Upload Package Results ${{ matrix.java }}
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Package Jar ${{ matrix.java }}
- path: target/*.jar
-
- build-21:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- max-parallel: 1
- matrix:
- # build against supported Java LTS versions:
- java: [ 21 ]
- name: Java ${{ matrix.java }}
- steps:
- - uses: actions/checkout@v3
- - name: Set up JDK ${{ matrix.java }}
- uses: actions/setup-java@v3
- with:
- distribution: 'temurin'
- java-version: ${{ matrix.java }}
- cache: 'maven'
- - name: Compile Java ${{ matrix.java }}
- run: mvn clean compile -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} -D maven.test.skip=true -D maven.site.skip=true -D maven.javadoc.skip=true
- - name: Run Tests ${{ matrix.java }}
- run: |
- mvn test -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
- - name: Build Test Report ${{ matrix.java }}
- if: ${{ always() }}
- run: |
- mvn surefire-report:report-only -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
- mvn site -D generateReports=false -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
- - name: Upload Test Results ${{ matrix.java }}
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Test Results ${{ matrix.java }}
- path: target/surefire-reports/
- - name: Upload Test Report ${{ matrix.java }}
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Test Report ${{ matrix.java }}
- path: target/site/
- - name: Package Jar ${{ matrix.java }}
- run: mvn clean package -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} -D maven.test.skip=true -D maven.site.skip=true
- - name: Upload Package Results ${{ matrix.java }}
- if: ${{ always() }}
- uses: actions/upload-artifact@v4
- with:
- name: Package Jar ${{ matrix.java }}
- path: target/*.jar
diff --git a/build.gradle b/build.gradle
index 3961e85..84aaee7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,15 +2,8 @@
* This file was generated by the Gradle 'init' task.
*/
apply plugin: 'java'
-apply plugin: 'eclipse'
-// apply plugin: 'jacoco'
apply plugin: 'maven-publish'
-//plugins {
- // id 'java'
- //id 'maven-publish'
-// }
-
repositories {
mavenLocal()
mavenCentral()
@@ -25,12 +18,8 @@ dependencies {
testImplementation 'org.mockito:mockito-core:4.2.0'
}
-subprojects {
- tasks.withType(Javadoc).all { enabled = false }
-}
-
-group = 'org.json'
-version = 'v20250107-SNAPSHOT'
+group = 'org.json.compat'
+version = 'v20250107-local'
description = 'JSON in Java'
sourceCompatibility = '1.8'
@@ -45,6 +34,7 @@ java {
publishing {
publications {
maven(MavenPublication) {
+ artifactId = 'json'
from(components.java)
}
}
@@ -66,7 +56,7 @@ task modifyStrictMode {
doLast {
println "Modifying JSONParserConfiguration.java to enable strictMode..."
- def filePath = project.file('src/main/java/org/json/JSONParserConfiguration.java')
+ def filePath = project.file('src/main/java/org/json/compat/JSONParserConfiguration.java')
if (!filePath.exists()) {
throw new GradleException("Could not find file: ${filePath.absolutePath}")
@@ -92,7 +82,7 @@ task restoreStrictMode {
doLast {
println "Restoring original JSONParserConfiguration.java..."
- def filePath = project.file('src/main/java/org/json/JSONParserConfiguration.java')
+ def filePath = project.file('src/main/java/org/json/compat/JSONParserConfiguration.java')
def backupFile = new File(filePath.absolutePath + '.bak')
if (backupFile.exists()) {
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index a4b4429..2733ed5 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 80c9b89..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,254 +0,0 @@
-
- 4.0.0
-
- org.json
- json
- 20250107
- bundle
-
- JSON in Java
-
- JSON is a light-weight, language independent, data interchange format.
- See http://www.JSON.org/
-
- The files in this package implement JSON encoders/decoders in Java.
- It also includes the capability to convert between JSON and XML, HTTP
- headers, Cookies, and CDL.
-
- This is a reference implementation. There are a large number of JSON packages
- in Java. Perhaps someday the Java community will standardize on one. Until
- then, choose carefully.
-
- https://github.com/douglascrockford/JSON-java
-
-
- https://github.com/douglascrockford/JSON-java.git
- scm:git:git://github.com/douglascrockford/JSON-java.git
- scm:git:git@github.com:douglascrockford/JSON-java.git
-
-
-
-
- Public Domain
- https://github.com/stleary/JSON-java/blob/master/LICENSE
- repo
-
-
-
-
-
- Douglas Crockford
- douglas@crockford.com
-
-
-
-
- UTF-8
-
-
-
-
-
- ossrh
- Central Repository OSSRH
- https://oss.sonatype.org/service/local/staging/deploy/maven2/
-
-
- ossrh
- https://oss.sonatype.org/content/repositories/snapshots
-
-
-
-
-
-
- junit
- junit
- 4.13.2
- test
-
-
- com.jayway.jsonpath
- json-path
- 2.9.0
- test
-
-
- org.mockito
- mockito-core
- 4.2.0
- test
-
-
-
-
-
-
- org.apache.felix
- maven-bundle-plugin
- 5.1.9
- true
-
-
-
- org.json
-
- ${project.artifactId}
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.11.0
-
- 1.8
- 1.8
-
- -Xlint:unchecked
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 3.3.0
-
-
- attach-sources
-
- jar-no-fork
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 3.5.0
-
-
- attach-javadocs
-
- jar
-
-
- -Xdoclint:none
-
-
-
-
-
- org.apache.maven.plugins
- maven-gpg-plugin
- 1.6
-
-
- sign-artifacts
- verify
-
- sign
-
-
-
- --pinentry-mode
- loopback
-
-
-
-
-
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.3
- true
-
- ossrh
- https://oss.sonatype.org/
- false
-
-
-
- org.moditect
- moditect-maven-plugin
- 1.0.0.Final
-
-
- add-module-infos
- package
-
- add-module-info
-
-
- 9
-
-
- module org.json {
- exports org.json;
- }
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 3.3.0
-
-
-
-
-
- test-strict-mode
-
-
-
- com.google.code.maven-replacer-plugin
- replacer
- 1.5.3
-
-
-
- enable-strict-mode
- process-sources
-
- replace
-
-
- src/main/java/org/json/JSONParserConfiguration.java
-
-
- // this.strictMode = true;
- this.strictMode = true;
-
-
-
-
-
-
- restore-original
- test
-
- replace
-
-
- src/main/java/org/json/JSONParserConfiguration.java
-
-
- this.strictMode = true;
- // this.strictMode = true;
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/main/java/org/json/CDL.java b/src/main/java/org/json/compat/CDL.java
similarity index 95%
rename from src/main/java/org/json/CDL.java
rename to src/main/java/org/json/compat/CDL.java
index dd631bf..143e845 100644
--- a/src/main/java/org/json/CDL.java
+++ b/src/main/java/org/json/compat/CDL.java
@@ -1,4 +1,4 @@
-package org.json;
+package org.json.compat;
/*
Public Domain.
@@ -100,15 +100,11 @@ public class CDL {
for (;;) {
String value = getValue(x,delimiter);
char c = x.next();
- if (value != null) {
- ja.put(value);
- } else if (ja.length() == 0 && c != delimiter) {
+ if (value == null ||
+ (ja.length() == 0 && value.length() == 0 && c != delimiter)) {
return null;
- } else {
- // This line accounts for CSV ending with no newline
- ja.put("");
}
-
+ ja.put(value);
for (;;) {
if (c == delimiter) {
break;
@@ -311,17 +307,6 @@ public class CDL {
if (ja.length() == 0) {
return null;
}
-
- // The following block accounts for empty datasets (no keys or vals)
- if (ja.length() == 1) {
- JSONObject j = ja.getJSONObject(0);
- if (j.length() == 1) {
- String key = j.keys().next();
- if ("".equals(key) && "".equals(j.get(key))) {
- return null;
- }
- }
- }
return ja;
}
diff --git a/src/main/java/org/json/Cookie.java b/src/main/java/org/json/compat/Cookie.java
similarity index 99%
rename from src/main/java/org/json/Cookie.java
rename to src/main/java/org/json/compat/Cookie.java
index ab908a3..33ed3e2 100644
--- a/src/main/java/org/json/Cookie.java
+++ b/src/main/java/org/json/compat/Cookie.java
@@ -1,4 +1,4 @@
-package org.json;
+package org.json.compat;
import java.util.Locale;
diff --git a/src/main/java/org/json/CookieList.java b/src/main/java/org/json/compat/CookieList.java
similarity index 98%
rename from src/main/java/org/json/CookieList.java
rename to src/main/java/org/json/compat/CookieList.java
index d1064db..52d444d 100644
--- a/src/main/java/org/json/CookieList.java
+++ b/src/main/java/org/json/compat/CookieList.java
@@ -1,4 +1,4 @@
-package org.json;
+package org.json.compat;
/*
Public Domain.
diff --git a/src/main/java/org/json/HTTP.java b/src/main/java/org/json/compat/HTTP.java
similarity index 99%
rename from src/main/java/org/json/HTTP.java
rename to src/main/java/org/json/compat/HTTP.java
index 44ab3a6..ade9203 100644
--- a/src/main/java/org/json/HTTP.java
+++ b/src/main/java/org/json/compat/HTTP.java
@@ -1,4 +1,4 @@
-package org.json;
+package org.json.compat;
/*
Public Domain.
diff --git a/src/main/java/org/json/HTTPTokener.java b/src/main/java/org/json/compat/HTTPTokener.java
similarity index 98%
rename from src/main/java/org/json/HTTPTokener.java
rename to src/main/java/org/json/compat/HTTPTokener.java
index 48cad31..f30b4e8 100644
--- a/src/main/java/org/json/HTTPTokener.java
+++ b/src/main/java/org/json/compat/HTTPTokener.java
@@ -1,4 +1,4 @@
-package org.json;
+package org.json.compat;
/*
Public Domain.
diff --git a/src/main/java/org/json/JSONArray.java b/src/main/java/org/json/compat/JSONArray.java
similarity index 94%
rename from src/main/java/org/json/JSONArray.java
rename to src/main/java/org/json/compat/JSONArray.java
index e2725b7..d1f2058 100644
--- a/src/main/java/org/json/JSONArray.java
+++ b/src/main/java/org/json/compat/JSONArray.java
@@ -1,4 +1,4 @@
-package org.json;
+package org.json.compat;
/*
Public Domain.
@@ -75,19 +75,20 @@ public class JSONArray implements Iterable