Skip to content

Commit cd55742

Browse files
committed
Version 1.1.0 (added Instants/date-time)
1 parent 8623e1b commit cd55742

File tree

7 files changed

+225
-509
lines changed

7 files changed

+225
-509
lines changed

README.md

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# json5 [![javadoc](https://img.shields.io/endpoint?label=javadoc&url=https%3A%2F%2Fjavadoc.syntaxerror.at%2Fjson5%2F%3Fbadge%3Dtrue)](https://javadoc.syntaxerror.at/json5/latest) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Synt4xErr0r4/json5/Java%20CI%20with%20Maven)
1+
# json5 [![javadoc](https://img.shields.io/endpoint?label=javadoc&url=https%3A%2F%2Fjavadoc.syntaxerror.at%2Fjson5%2F%3Fbadge%3Dtrue%26version%3D1.1.0)](https://javadoc.syntaxerror.at/json5/1.1.0) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/Synt4xErr0r4/json5/Java%20CI%20with%20Maven)
22

3-
A JSON5 Library for Java (11+)
3+
A JSON5 Library for Java (11+)
4+
5+
*This branch contains features of the unreleased [version 1.1.0](https://github.com/json5/json5-spec/milestone/2)*
46

57
## Overview
68

@@ -10,7 +12,7 @@ This is a reference implementation, capable of parsing JSON5 data according to t
1012

1113
## Getting started
1214

13-
In order to use the code, you can either [download the jar](), or use the Maven dependency:
15+
In order to use the code, you can either [download the jar](https://github.com/Synt4xErr0r4/json5/releases/download/1.1.0/json5-1.1.0.jar), or use the Maven dependency:
1416
```xml
1517
<!-- Repository -->
1618

@@ -24,7 +26,7 @@ In order to use the code, you can either [download the jar](), or use the Maven
2426
<dependency>
2527
<groupId>at.syntaxerror</groupId>
2628
<artifactId>json5</artifactId>
27-
<version>1.0.0</version>
29+
<version>1.1.0</version>
2830
</dependency>
2931
```
3032

@@ -102,7 +104,7 @@ Calling `json.toString(indentFactor)` is the same as `JSONStringify.toString(jso
102104

103105
The `getXXX` methods are used to read values from the JSON object/ array.
104106
The `set` methods are used to override or set values in the JSON object/ array.
105-
The `add` methods are used to add values to a JSON array.
107+
The `add` and `insert` methods are used to add values to a JSON array.
106108

107109
Supported data types are:
108110
- `boolean`
@@ -114,6 +116,7 @@ Supported data types are:
114116
- `String`
115117
- `JSONObject`
116118
- `JSONArray`
119+
- `Instants` (since `1.1.0`, see below)
117120

118121
The normal `getXXX(String key)` and `getXXX(int index)` methods will throw an exception if the specified key or index does not exist, but the
119122
`getXXX(String key, XXX defaults)` and `getXXX(int index, XXX defaults)` methods will return the default value (parameter `defaults`) instead.
@@ -128,6 +131,36 @@ To check if a number can fit into a type, you can use the `getXXXExact` methods,
128131
Numbers are internally always stored as either a `java.math.BigInteger`, `java.math.BigDecimal`, or `double` (`double` is used for `Infinity` and `NaN` only). Therefore, any method
129132
returning raw `java.lang.Object`s will return numbers as one of those types. The same behaviour applies to the `getNumber` methods.
130133

134+
## Changelog
135+
### v1.1.0
136+
137+
Instants (date and time) are now supported. This option can be toggled via the options listed below.
138+
139+
The `JSONOptions` class allows you to customize the behaviour of the parser and stringifyer. It can be created via the builder subclass.
140+
You can also set the default options used if the supplied options are `null`, by using the method `setDefaultOptions(JSONOptions)`. The default options must not be `null`.
141+
142+
The following options are currently implemented:
143+
144+
- `parseInstants`: (default `true`, *Parser-only*) ([proposed here](https://github.com/json5/json5-spec/issues/4))
145+
Whether or not instants should be parsed as such.
146+
If this is `false`, `parseStringInstants` and `parseUnixInstants` are ignored
147+
- `parseStringInstants`: (default `true`, *Parser-only*) ([proposed here](https://github.com/json5/json5-spec/issues/4))
148+
Whether or not string instants (according to [RFC 3339, Section 5.6](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6)) should be parsed as such.
149+
Ignored if `parseInstants` is `false`
150+
- `parseUnixInstants`: (default `true`, *Parser-only*) ([proposed here](https://github.com/json5/json5-spec/issues/4))
151+
Whether or not unix instants (integers) should be parsed as such.
152+
Ignored if `parseInstants` is `false`
153+
- `stringifyUnixInstants`: (default `false`, *Stringify-only*) ([proposed here](https://github.com/json5/json5-spec/issues/4))
154+
Whether or not instants should be stringifyed as unix timestamps (integers).
155+
If this is `false`, instants will be stringifyed as strings (according to [RFC 3339, Section 5.6](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6))
156+
- `allowNaN`: (default `true`, *Parser-only*) ([proposed here](https://github.com/json5/json5-spec/issues/24))
157+
Whether or not `NaN` should be allowed as a number
158+
- `allowInfinity`: (default `true`, *Parser-only*) ([proposed here](https://github.com/json5/json5-spec/issues/24))
159+
Whether or not `Infinity` should be allowed as a number. This applies to both `+Infinity` and `-Infinity`
160+
- `allowInvalidSurrogates`: (default `true`, *Parser-only*) ([proposed here](https://github.com/json5/json5-spec/issues/12))
161+
Whether or not invalid unicode surrogate pairs should be allowed
162+
- `quoteSingle`: (default `false`, *Stringify-only*)
163+
Whether or not string should be single-quoted (`'`) instead of double-quoted (`"`). This also includes a JSONObject's member names
131164
## Documentation
132165

133166
The JavaDoc for the latest version can be found [here](https://javadoc.syntaxerror.at/json5/latest).

0 commit comments

Comments
 (0)