A reference implementation of a JSON package in Java.

Related tags

JSON-java
Overview

JSON in Java [package org.json]

Maven Central

Click here if you just want the latest release jar file.

Overview

JSON is a light-weight language-independent data interchange format.

The JSON-Java package is a reference implementation that demonstrates how to parse JSON documents into Java objects and how to generate new JSON documents from the Java classes.

Project goals include:

  • Reliable and consistent results
  • Adherence to the JSON specification
  • Easy to build, use, and include in other projects
  • No external dependencies
  • Fast execution and low memory footprint
  • Maintain backward compatibility
  • Designed and tested to use on Java versions 1.6 - 1.11

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

The license includes this restriction: "The software shall be used for good, not evil." If your conscience cannot live with that, then choose a different package.

If you would like to contribute to this project

Bug fixes, code improvements, and unit test coverage changes are welcome! Because this project is currently in the maintenance phase, the kinds of changes that can be accepted are limited. For more information, please read the FAQ.

Build Instructions

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.

Building from the command line

Build the class files from the package root directory src/main/java

javac org\json\*.java

Create the jar file in the current directory

jar cf json-java.jar org/json/*.class

Compile a program that uses the jar (see example code below)

javac -cp .;json-java.jar Test.java 

Test file contents

import org.json.JSONObject;
public class Test {
    public static void main(String args[]){
       JSONObject jo = new JSONObject("{ \"abc\" : \"def\" }");
       System.out.println(jo.toString());
    }
}

Execute the Test file

java -cp .;json-java.jar Test

Expected output

{"abc":"def"}

Tools to build the package and execute the unit tests

Execute the test suite with Maven:

mvn clean test

Execute the test suite with Gradlew:

gradlew clean build test

Notes

Recent directory structure change

Due to a recent commit - #515 Merge tests and pom and code - the structure of the project has changed from a flat directory containing all of the Java files to a directory structure that includes unit tests and several tools used to build the project jar and run the unit tests. If you have difficulty using the new structure, please open an issue so we can work through it.

Implementation notes

Numeric types in this package comply with ECMA-404: The JSON Data Interchange Format and RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format. This package fully supports Integer, Long, and Double Java types. Partial support for BigInteger and BigDecimal values in JSONObject and JSONArray objects is provided in the form of get(), opt(), and put() API methods.

Although 1.6 compatibility is currently supported, it is not a project goal and might be removed in some future release.

In compliance with RFC8259 page 10 section 9, the parser is more lax with what is valid JSON then the Generator. For Example, the tab character (U+0009) is allowed when reading JSON Text strings, but when output by the Generator, the tab is properly converted to \t in the string. Other instances may occur where reading invalid JSON text does not cause an error to be generated. Malformed JSON Texts such as missing end " (quote) on strings or invalid number formats (1.2e6.3) will cause errors as such documents can not be read reliably.

Some notable exceptions that the JSON Parser in this library accepts are:

  • Unquoted keys { key: "value" }
  • Unquoted values { "key": value }
  • Unescaped literals like "tab" in string values { "key": "value with an unescaped tab" }
  • Numbers out of range for Double or Long are parsed as strings

Recent pull requests added a new method putAll on the JSONArray. The putAll method works similarly to other put methods in that it does not call JSONObject.wrap for items added. This can lead to inconsistent object representation in JSONArray structures.

For example, code like this will create a mixed JSONArray, some items wrapped, others not:

SomeBean[] myArr = new SomeBean[]{ new SomeBean(1), new SomeBean(2) };
// these will be wrapped
JSONArray jArr = new JSONArray(myArr);
// these will not be wrapped
jArr.putAll(new SomeBean[]{ new SomeBean(3), new SomeBean(4) });

For structure consistency, it would be recommended that the above code is changed to look like 1 of 2 ways.

Option 1:

SomeBean[] myArr = new SomeBean[]{ new SomeBean(1), new SomeBean(2) };
JSONArray jArr = new JSONArray();
// these will not be wrapped
jArr.putAll(myArr);
// these will not be wrapped
jArr.putAll(new SomeBean[]{ new SomeBean(3), new SomeBean(4) });
// our jArr is now consistent.

Option 2:

SomeBean[] myArr = new SomeBean[]{ new SomeBean(1), new SomeBean(2) };
// these will be wrapped
JSONArray jArr = new JSONArray(myArr);
// these will be wrapped
jArr.putAll(new JSONArray(new SomeBean[]{ new SomeBean(3), new SomeBean(4) }));
// our jArr is now consistent.

Unit Test Conventions

Test filenames should consist of the name of the module being tested, with the suffix "Test". For example, Cookie.java is tested by CookieTest.java.

The fundamental issues with JSON-Java testing are:

  • JSONObjects are unordered, making simple string comparison ineffective.
  • Comparisons via equals() is not currently supported. Neither JSONArray nor JSONObject override hashCode() or equals(), so comparison defaults to the Object equals(), which is not useful.
  • Access to the JSONArray and JSONObject internal containers for comparison is not currently available.

General issues with unit testing are:

  • Just writing tests to make coverage goals tends to result in poor tests.
  • Unit tests are a form of documentation - how a given method works is demonstrated by the test. So for a code reviewer or future developer looking at code a good test helps explain how a function is supposed to work according to the original author. This can be difficult if you are not the original developer.
  • It is difficult to evaluate unit tests in a vacuum. You also need to see the code being tested to understand if a test is good.
  • Without unit tests, it is hard to feel confident about the quality of the code, especially when fixing bugs or refactoring. Good tests prevent regressions and keep the intent of the code correct.
  • If you have unit test results along with pull requests, the reviewer has an easier time understanding your code and determining if it works as intended.

Files

JSONObject.java: The JSONObject can parse text from a String or a JSONTokener to produce a map-like object. The object provides methods for manipulating its contents, and for producing a JSON compliant object serialization.

JSONArray.java: The JSONArray can parse text from a String or a JSONTokener to produce a vector-like object. The object provides methods for manipulating its contents, and for producing a JSON compliant array serialization.

JSONTokener.java: The JSONTokener breaks a text into a sequence of individual tokens. It can be constructed from a String, Reader, or InputStream. It also can parse text from a String, Number, Boolean or null like "hello", 42, true, null to produce a simple json object.

JSONException.java: The JSONException is the standard exception type thrown by this package.

JSONPointer.java: Implementation of JSON Pointer (RFC 6901). Supports JSON Pointers both in the form of string representation and URI fragment representation.

JSONPropertyIgnore.java: Annotation class that can be used on Java Bean getter methods. When used on a bean method that would normally be serialized into a JSONObject, it overrides the getter-to-key-name logic and forces the property to be excluded from the resulting JSONObject.

JSONPropertyName.java: Annotation class that can be used on Java Bean getter methods. When used on a bean method that would normally be serialized into a JSONObject, it overrides the getter-to-key-name logic and uses the value of the annotation. The Bean processor will look through the class hierarchy. This means you can use the annotation on a base class or interface and the value of the annotation will be used even if the getter is overridden in a child class.

JSONString.java: The JSONString interface requires a toJSONString method, allowing an object to provide its own serialization.

JSONStringer.java: The JSONStringer provides a convenient facility for building JSON strings.

JSONWriter.java: The JSONWriter provides a convenient facility for building JSON text through a writer.

CDL.java: CDL provides support for converting between JSON and comma delimited lists.

Cookie.java: Cookie provides support for converting between JSON and cookies.

CookieList.java: CookieList provides support for converting between JSON and cookie lists.

HTTP.java: HTTP provides support for converting between JSON and HTTP headers.

HTTPTokener.java: HTTPTokener extends JSONTokener for parsing HTTP headers.

XML.java: XML provides support for converting between JSON and XML.

JSONML.java: JSONML provides support for converting between JSONML and XML.

XMLTokener.java: XMLTokener extends JSONTokener for parsing XML text.

Release history:

JSON-java releases can be found by searching the Maven repository for groupId "org.json" and artifactId "json". For example: https://search.maven.org/search?q=g:org.json%20AND%20a:json&core=gav

20210307    Recent commits and potentially breaking fix to JSONPointer

20201115    Recent commits and first release after project structure change

20200518    Recent commits and snapshot before project structure change

20190722    Recent commits

20180813    POM change to include Automatic-Module-Name (#431)

20180130    Recent commits

20171018    Checkpoint for recent commits.

20170516    Roll up recent commits.

20160810    Revert code that was breaking opt*() methods.

20160807    This release contains a bug in the JSONObject.opt*() and JSONArray.opt*() methods,
it is not recommended for use.
Java 1.6 compatability fixed, JSONArray.toList() and JSONObject.toMap(),
RFC4180 compatibility, JSONPointer, some exception fixes, optional XML type conversion.
Contains the latest code as of 7 Aug 2016

20160212    Java 1.6 compatibility, OSGi bundle. Contains the latest code as of 12 Feb 2016.

20151123    JSONObject and JSONArray initialization with generics. Contains the latest code as of 23 Nov 2015.

20150729    Checkpoint for Maven central repository release. Contains the latest code
as of 29 July 2015.
Issues
  • I would like to strictly name the module

    I would like to strictly name the module

    Hi There,

    I would like to update the pom and build to generate the module-info class file, and strictly name this module.

    Currently as an automatic module, you cannot perform a lot of JPMS functions, such as requires transitive, or evade the maven central deploy warning for unnamed modules.

    This is purely the raw code, could I get a zip of the build and send back a finished zip for perusal?

    opened by GedMarc 50
  • JSONObject and JSONArray initialization:

    JSONObject and JSONArray initialization:

    JSONObject(Map<String, ?> map) allows to initialize the JSONObject with a Map<String, String>

    JSONArray(Collection<?> collection) allows to initialize a JSONArray with a Collection<JSONObject>

    tests:

    public static void testJSONObjectWithStringMap(){
        Map<String, String> pairs = new HashMap<String, String>();
        pairs.put("one", "two");
        JSONObject j = new JSONObject(pairs);
        System.out.println(j);
        System.out.println(pairs);
        // what is wrong? --> since Map<String, String> cannot be mapped to Map<String, Object> 
        // the new JSONObject is being initialized with JSONObject(Object bean)
    }
    
    public static void testJSONArrayWithCollectionOfJSONObject(){
        List<JSONObject> jsonObjects = new ArrayList<JSONObject>();
        jsonObjects.add(new JSONObject().put("one", 1));
        jsonObjects.add(new JSONObject().put("two", 2));
        JSONArray jsonArray = new JSONArray(jsonObjects);
        System.out.println(jsonArray);
        // what is wrong? --> since Collection<Object> cannot be mapped to Collection<JSONObject>
        // the new JSONArray is being initialized with JSONArray(Object array)
    }
    
    opened by treyerl 44
  • XML.toJSONObject() crashes if CDATA is part of XML

    XML.toJSONObject() crashes if CDATA is part of XML

    in relation to: http://stackoverflow.com/questions/29283261/converting-xml-to-json-android

    I have the same issue too ans ask me, why "No virtual method end()Z in class Lorg/json/XMLTokener".

    Any ideas?

    opened by AppWerft 40
  • Use Appendable in place of Writer

    Use Appendable in place of Writer

    This change modifies JSONWriter to take an Appendable instead of a Writer as its constructor parameter. Appendable is an interface implemented by Writer, as well as classes such as StringBuilder.

    This refactor allows JSONStringer to use a StringBuilder directly, instead of a StringWriter.

    It also flows through to writeValue() in JSONObject. This in turn allows valueToString() to be simplified, simply delegating to writeValue() with StringBuilder as a parameter.

    I ran the test suite in JSON-Java-unit-test, which continues to pass. The code coverage varies in minor ways in JSONObject, JSONArray, and JSONWriter, due to the code reorganisation.

    opened by run2000 33
  • JSONTokener recognizes -0 as a string not as a number, based on usage from json-schema

    JSONTokener recognizes -0 as a string not as a number, based on usage from json-schema

    See: https://github.com/everit-org/json-schema/issues/25

    opened by coderextreme 27
  • JSONObject.write(Writer writer, int indentFactor, int indent) Not public

    JSONObject.write(Writer writer, int indentFactor, int indent) Not public

    I'm not sure if this is me or the library but when I attempt to use JSONObject.write(Writer writer, int indentFactor, int indent) I get an error saying the method is not visible. If I open the .class file I can see the method as public. I am using the latest version from mavenCentral() using gradle. This is the class where I call the method:

    package json;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    
    import org.json.JSONException;
    import org.json.JSONObject;
    
    public class JSONTest {
    
    	public void doStuff() {
    		
    		JSONObject obj = JSONUtils.getJSONObjectFromFile("json/obj.json");
    		
    		obj.put("Test", "MandM635");
    		
    		String[] names = JSONObject.getNames(obj);
    		
    		if(names == null) {
    			System.out.println("JSON File had no names!");
    			return;
    		}
    		
    		for(String string : names) {
    			System.out.println(string + ": " + obj.get(string));
    		}
    		
    		try {
    			PrintWriter writer = new PrintWriter("src/main/resources/json/obj.json", "UTF-8");
    
                            //This is the error
    			obj.write(writer, 1, 0);
    			
    			writer.close();
    		} catch (IOException | JSONException e) {
    			e.printStackTrace();
    		}
    	}
    }
    
    opened by MitchellShapiro 26
  • Having issue while convertnig xml with single element to json array or vice versa

    Having issue while convertnig xml with single element to json array or vice versa

    Please have a look at - http://stackoverflow.com/questions/42900503/json-xml-converter-having-array-in-json-string/42901710#42901710

    http://heshans.blogspot.in/2014/01/java-library-to-convert-xml-to-json.html

    I am getting json array for below xml -

    <readResult><errors><code>400</code></errors><errors><code>402</code></errors></readResult>
    {"readResult":{"errors":[{"code":400},{"code":402}]}}
    

    but, we need similar behavior while converting json to xml and back again where json array is having single element i.e.

    input json - {"readResult": {"errors": [{"code": 400}]}}
    converted xml - <readResult><errors><code>400</code></errors></readResult>
    output json - {"readResult":{"errors":{"code":400}}}
    
    opened by rvashishth 25
  • Uses superclass Number instead of specific sub classes

    Uses superclass Number instead of specific sub classes

    see issue #126

    opened by johnjaylward 24
  • JSONArray does not have constructor to allocate the specified initial capacity

    JSONArray does not have constructor to allocate the specified initial capacity

    The collection class like ArrayList has the constructor that accepts the number as an input to "Constructs an empty list with the specified initial capacity."
    The absence of this functionality in the JSONArray will not affect the performance of the smaller applications with a fairly limited number of iteration, but the huge applications that involve a large number of iterations will result in the performance trade-off because ArrayList grows or expands numerous times.

    opened by viveksacademia4git 23
  • Added type conversion support

    Added type conversion support

    The lib doesn't support type conversion for a specific value. I have added the feature to support type conversion for a specific tag. Example:

    //XML String <root><id1 xsi:type="java.lang.String">1234</id1><id2 xsi:type="java.lang.Integer">1234</id2></root>

    //Corresponding JSON String {"root":{"id2":1234,"id1":"1234"}}

    Approved 
    opened by kumar529 21
  • Fixed incorrect cast getting float from array

    Fixed incorrect cast getting float from array

    Hello,

    I noticed that if a double is added to a JSONArray and then retrieved with getFloat(), a class cast exception was raised. This case is handled correctly by JSONObject (as opposed to array).

    The root cause turned out to be an incorrect cast. I corrected the cast and also added a test for this case. I tried to closely follow the existing coding conventions as well as the corresponding code in JSONObject.

    Please let me know if you need any more information. Thanks for maintaining this project!

    Sincerely, Ian Lovejoy

    Approved - 3-day window 
    opened by ianlovejoy 5
  • Suggestion type support

    Suggestion type support

    I've seen the possible API changes within the FAQ, and it occurred to me if a possible improvement is to add support for the Fraction type. I've been using it quite a bit and find it quite useful. Before starting the implementation to support it, I would like to know if it would be an accepted change or not.

    The fraction type I've been using: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/math/Fraction.html

    Awaiting further input from submitter 
    opened by pabramber01 2
  • New logo for the project

    New logo for the project

    As we have seen the project doesn't have any logo yet, we have created a sketch and suggested it as an improvement. image

    Active discussion 
    opened by IsmaelP19 10
  • How to convert a node of xml to json array

    How to convert a node of xml to json array

    This is achieved in python, is it possible to add similar parameters in java

    In the following example, interfaces are parsed into an array as expected

    import json
    
    import xmltodict
    
    t1 = '''
    <servers>
      <server>
        <name>host1</name>
        <os>Linux</os>
        <interfaces>
          <interface>
            <name>em0</name>
            <ip_address>10.0.0.1</ip_address>
          </interface>
        </interfaces>
      </server>
    </servers>
    '''
    content = xmltodict.parse(t1, force_list=['servers', 'interfaces'])
    data_str = json.dumps(content)
    print(data_str)
    
    

    output

    {
      "servers": [
        {
          "server": {
            "name": "host1",
            "os": "Linux",
            "interfaces": [
              {
                "interface": {
                  "name": "em0",
                  "ip_address": "10.0.0.1"
                }
              }
            ]
          }
        }
      ]
    }
    

    is it possible to add similar parameters in java?

    public JSONObject parse(String content, List<String> forceList) {
            // to be
            return  org.json.XML.toJSONObject(content);
        }
    
    Active discussion 
    opened by relax-admin 1
  • how to make a pretty-printed XML text from JSONObject?

    how to make a pretty-printed XML text from JSONObject?

    org.json.JSONObject#toString(int) has an indentFactor parameter, but org.json.XML.toString does not have an indentFactor parameter

    Active discussion 
    opened by xiejx618 1
  • Need to complete the unit tests for JSONPointer

    Need to complete the unit tests for JSONPointer

    See the discussion about unit tests in #588. The code has been merged, but should not be released until all of the suggested unit tests have been implemented. Unit tests that are mentioned in the comments and already in place should be refactored if they do not clearly show the expected result in the code. For example, this code:

        @Test
        public void objectPropertyQuery() {
            assertSame(document.get("foo"), query("/foo"));
        }
    

    Could be refactored to:

        @Test
        public void objectPropertyQuery() {
            assertSame(document.get("foo"), query("/foo"));
            assertEquals(query("/foo").toString(), "[\"bar\",\"baz\"]");
        }
    
    opened by stleary 0
  • JSONObject#similar() fails to consider similar a number with/without trailing zero

    JSONObject#similar() fails to consider similar a number with/without trailing zero

    Hello, as confirmed by #134 , numbers 1 and 1.0 should be considered the same in JSON. However, the method JSONObject#similar(Object) does not. Here is a simple test:

    final JSONObject jsonWithTrailing0 = new JSONObject("{\"name\": 1.0}");
    System.out.println(jsonWithTrailing0.toString()); // {"name":1}
    final JSONObject jsonWithoutTrailing0 = new JSONObject("{\"name\": 1}");
    Assert.assertTrue("Not the same!", jsonWithTrailing0.similar(jsonWithoutTrailing0)); // AssertionError: Not the same!
    
    Active discussion Release scheduled 
    opened by cdanger 5
  • Length of String e in unescapeEntity(String e) method should be checked before parsing

    Length of String e in unescapeEntity(String e) method should be checked before parsing

    The length of String e in the unescapeEntity( String e) should be checked in line 170 in XMLTokenerClass , because if the value of e is "#" then there may be an issue. The line

     if (e.charAt(1) == 'x' || e.charAt(1) == 'X') {
    

    may be changed to

                if ((e.length() >1) && (e.charAt(1) == 'x' || e.charAt(1) == 'X')) {
    
    Active discussion 
    opened by ek08 11
  • Preserve insertion order when stringifing JSONObject

    Preserve insertion order when stringifing JSONObject

    Sure, the specs don't specify an ordering (as correctly pointed out in the javadocs), but a particular implementation - such as this one - can provide some ordering semantics. It is not wrong if an implementation is opinionated, there is just no definition in the json spec about this should be done.

    So why not using LinkedHashMap instead of HashMap in https://github.com/stleary/JSON-java/blob/master/src/main/java/org/json/JSONObject.java#L178? This would improve (human) readability by preserving insertion order when printing json.

    Active discussion Keep open 
    opened by holgerbrandl 4
  • Where is the API documentation?

    Where is the API documentation?

    • in the code no doubt. But I just spent half an hour not finding how to get a named string attribute from a JSONObject... A 'getting started' entry about how easy it is to use this package would not go astray. P
    Still a concern 
    opened by petercwallis 10
Releases(20210307)
  • 20210307(Mar 7, 2021)

    | Pull Request | Description | |---------------|--------------| | #575 | Fix similar compare numbers | | #577 | Added clear() methods to JSONObject and JSONArray | | #581 | Use built-in Gradle shorthand notation for Maven Central repository | | #583 | Checked the length of key for checker framework | | #588 | JSONPointer should not process reverse solidus or double-quote chars in tokens |

    NOTE:

    #588 is a potentially breaking change to JSONPointer. Embedded double quote and backslash chars are now handled differently (they are basically ignored by the JSONPointer parser). If this causes problems to your project, post an issue on the JSON-Java GitHub page.

    Source code(tar.gz)
    Source code(zip)
  • 20201115(Nov 15, 2020)

    | Pull Request | Description | |---------------|--------------| | #515 | Merge tests and pom and code | | #519 | Gradle support | | #521 | Updates Cookie class to be more generic in attribute parsing and emit | | #524 | JSONArray does not have constructor to allocate the specified initial capacity | | #525 | Unit test fixes | | #526| Comment out some broken unit tests | | #527 | Fixes for Unit tests and supports GitHub Actions | | #529 | Added putAll(Collection) and putAll(Array) methods | | #532 | Verifies BigDecimal support does not have a regression| | #538 | Explain local builds in the readme, fix a couple of typos | | #539 | Bring Junit tests to Java 1.6 compatibility | | #540 | Added type conversion support | | #542 | Fix xml hex entity parse | | #543 | Refactor XMLConfiguration to use Builder Pattern | | #549 | Update readme.md | | #552 | Updates for JSONArray.putAll methods | | #570 | Readme - fix spelling and usage, per Grammarly |

    Source code(tar.gz)
    Source code(zip)
  • 20200518(May 17, 2020)

    | Pull Request | Description | |---------------|--------------| | #502 | Update JSONTokener text in README | | #499 | Add copyright to some files | | #495 | Refactor typos from code | | #494 | Replace JSONObject constructor string arrays with var args | | #492 | Clarify output of JSONArray toList() | | #486 | Standardize some exception messages | | #485 | Fix EOF error when Meta tag isn't closed at end of input. | | #483 | Update README.md to point to latest released jar | | #481 | Clarify exception when parser reads JSON | | #475 |Make private methods static where possible | | #474 | Replaces an internally used inefficient StringBuffer class |

    Source code(tar.gz)
    Source code(zip)
  • 20190722(Jul 22, 2019)

    | Pull Request | Description | |---------------|--------------| | #467 | add configuration for xsi:nil="true" conversion to null | | #452 | Adds check for EOF | | #440 | Corrections to BigDecimal consistency | | #432|Update README.md | |#421 |add isEmpty and isNotEmpty methods | |#417 |fix double ctor in JSONWriter | |#412 |Initial implementation of XMLParserConfig object for flexible XML Parsing | | #407 | Fix for invalid processing of trailing / for JSON Pointer | | #406 | Adds annotations to customize field names during Bean serialization |

    Source code(tar.gz)
    Source code(zip)
  • 20180813(Aug 13, 2018)

    Pull Request | Description ---- | ---- #405 | Update javadoc to match actual exceptions thrown. #403 | Ignore Intellij Idea project files #400 | XML toJSONObject(Reader reader)

    Source code(tar.gz)
    Source code(zip)
  • 20180130(Jan 30, 2018)

    Pull Request | Description ------------ | ------------- #392| Remove wrong apostrophe #381 | Adding maven badge to readme #380 | Fix for false positives in similar functions #375 | fixes wrapped exceptions #373 | Fixes Unclosed json array stack overflow

    Source code(tar.gz)
    Source code(zip)
  • 20171018(Oct 17, 2017)

    Pull Request | Description ------------ | ------------- #362 | Fixes XML Unescaping #360 | Creating a JSONObject from a string that contains a duplicate key (any level) throws a JSONException that includes location #357 | Update javadoc according to issue #356 #354 | Updates for populateMap based on discussion in #279 and #264 #352 | Error message position fixes #348 | Capacity improvements for internal structures #347 | A comment added to explain the use of HashMap #345 | Adds JSONException for write value errors #341 | Optimize loops #337 | Optimizes opt* functions #336 | Numeric enhancements, Refactoring, Fix spelling

    Source code(tar.gz)
    Source code(zip)
  • 20170516(May 16, 2017)

    Pull Request | Description ------------ | ------------- #324 | Allow user to invoke query and optQuery ,with a JSONPointer #317 | make sure locale independent data is not upper/lowercased incorrectly #304 | Update README #292 | Provides "#" string evaluation support for JSON Pointer #288 | Bug fixes for XML Encoding and Decoding #274 | Fix for number output bug. #271 | Update enum support to be more fully featured.

    Source code(tar.gz)
    Source code(zip)
  • 20160810(Aug 10, 2016)

  • 20160807(Aug 7, 2016)

    | Pull Request | Description | | --- | --- | | https://github.com/stleary/JSON-java/pull/253 | Optional type conversion for XML reading | | https://github.com/stleary/JSON-java/pull/249 | Reduce the use of unnecessary exceptions | | https://github.com/stleary/JSON-java/pull/246 | Add License file | | https://github.com/stleary/JSON-java/pull/242 | Update readme | | https://github.com/stleary/JSON-java/pull/236 | Make nextString throw a JSONException instead of a NumberFormatException | | https://github.com/stleary/JSON-java/pull/234 | JSONPointer fix | | https://github.com/stleary/JSON-java/pull/226 | fix to compile with 1.6.0_45 | | https://github.com/stleary/JSON-java/pull/222 | JSON Pointer implementation | | https://github.com/stleary/JSON-java/pull/219 | Added CSV change to CDL.java | | https://github.com/stleary/JSON-java/pull/203 | Adds JSONArray toList method and JSONObject toMap method |

    Source code(tar.gz)
    Source code(zip)
  • 20160212(Feb 12, 2016)

    Extending backwards compatibility to Java 1.6. The unit tests [https://github.com/stleary/JSON-Java-unit-test] still require Java 1.8. Includes the following commits:

    | Pull Request | Description | | --- | --- | | https://github.com/stleary/JSON-java/pull/195 | Java 1.6 compatibility | | https://github.com/stleary/JSON-java/pull/188 | Fix negative zero | | https://github.com/stleary/JSON-java/pull/186 | Update README with number information | | https://github.com/stleary/JSON-java/pull/185 | change to public: write(writer, indentfactor, indent) | | https://github.com/stleary/JSON-java/pull/180 | Remove executable bit | | https://github.com/stleary/JSON-java/pull/179 | Update JavaDoc for JSONObject Constructors |

    Source code(tar.gz)
    Source code(zip)
  • 20151123(Nov 24, 2015)

    Support initializing a JSONObject with Map<?,?> and JSONArray with Collection<?>. Includes the following commits:

    | Pull request | Description | | --- | --- | | #168 | Update Readme for Maven release | | #160 | Fixe possible NullPointerException | | #159 | Properly override Exception class | | #153 | JSONObject and JSONArray initialization |

    Source code(tar.gz)
    Source code(zip)
  • 20150729(Sep 20, 2015)

    Code changes since the most recent Maven release (20141113):

    | Existing feature enhancements | Pull request | | --- | --- | | New methods for Enum type | https://github.com/douglascrockford/JSON-java/pull/140 | | BigDecimal and BigInteger methods | https://github.com/douglascrockford/JSON-java/pull/135 | | Iterable JSONArray | https://github.com/douglascrockford/JSON-java/pull/132 | | Remove compiler cast warnings | https://github.com/douglascrockford/JSON-java/pull/122 | | JavaDoc fix in CDL | https://github.com/douglascrockford/JSON-java/pull/120 | | Fix for JSONML.toString() | https://github.com/douglascrockford/JSON-java/pull/118 | | Fix for JSONArray.toString() | (direct commit) https://github.com/douglascrockford/JSON-java/commit/d6ba31819c48db39be068c8b3b1fa985df09ea65 |

    Source code(tar.gz)
    Source code(zip)
Compare JSON in your Unit Tests

JsonUnit JsonUnit is a library that simplifies JSON comparison in tests. APIs AssertJ integration Hamcrest matchers Spring MVC assertions Spring WebTe

Lukáš Křečan 529 Mar 12, 2021
High performance JVM JSON library

DSL-JSON library Fastest JVM (Java/Android/Scala/Kotlin) JSON library with advanced compile-time databinding support. Compatible with DSL Platform. Ja

New Generation Software Ltd 704 Mar 11, 2021
Main Portal page for the Jackson project

Jackson Project Home @github This is the home page of the Jackson Project. What is New? Oct 1, 2020: Jackson participates in Hacktoberfest2020 and we

FasterXML, LLC 6.5k Apr 29, 2021
A modern JSON library for Kotlin and Java.

Moshi Moshi is a modern JSON library for Android and Java. It makes it easy to parse JSON into Java objects: String json = ...; Moshi moshi = new Mos

Square 7.1k Mar 13, 2021
A reference implementation of a JSON package in Java.

JSON in Java [package org.json] Click here if you just want the latest release jar file. Overview JSON is a light-weight language-independent data int

Sean Leary 3.8k Apr 29, 2021
A JSON Schema validation implementation in pure Java, which aims for correctness and performance, in that order

Read me first The current version of this project is licensed under both LGPLv3 (or later) and ASL 2.0. The old version (2.0.x) was licensed under LGP

Java Json Tools 1.4k Mar 14, 2021
Convert Java to JSON. Convert JSON to Java. Pretty print JSON. Java JSON serializer.

json-io Perfect Java serialization to and from JSON format (available on Maven Central). To include in your project: <dependency> <groupId>com.cedar

John DeRegnaucourt 272 Feb 20, 2021
Java JsonPath implementation

Jayway JsonPath A Java DSL for reading JSON documents. Jayway JsonPath is a Java port of Stefan Goessner JsonPath implementation. News 10 Dec 2020 - R

null 5.7k Mar 13, 2021
Java JsonPath implementation

Jayway JsonPath A Java DSL for reading JSON documents. Jayway JsonPath is a Java port of Stefan Goessner JsonPath implementation. News 10 Dec 2020 - R

null 5.7k Mar 15, 2021
A streaming JsonPath processor in Java

JsonSurfer - Let's surf on Json! Why JsonSurfer Streaming No need to deserialize entire json into memory. JsonPath Selectively extract json data by th

null 201 Feb 4, 2021
JSON to JSON transformation library written in Java.

Jolt JSON to JSON transformation library written in Java where the "specification" for the transform is itself a JSON document. Useful For Transformin

Bazaarvoice 1k Mar 11, 2021
Fast JSON parser for java projects

ig-json-parser Fast JSON parser for java projects. Getting started The easiest way to get started is to look at maven-example. For more comprehensive

Instagram 1.3k Mar 7, 2021
Lean JSON Library for Java, with a compact, elegant API.

mJson is an extremely lightweight Java JSON library with a very concise API. The source code is a single Java file. The license is Apache 2.0. Because

Borislav Iordanov 69 Apr 15, 2021
Genson a fast & modular Java <> Json library

Genson Genson is a complete json <-> java conversion library, providing full databinding, streaming and much more. Gensons main strengths? Easy to use

null 197 Feb 26, 2021