Skip to content

Releases: tayloraswift/swift-json

2.3.1

14 Mar 20:08
b49d387

Choose a tag to compare

What's Changed

Full Changelog: 2.3.0...2.3.1

2.3.0

04 Feb 00:52
95d1930

Choose a tag to compare

What's Changed

  • jsvalue becomes a struct, to align with actual JavaScriptKit by @tayloraswift in #104

Full Changelog: 2.2.0...2.3.0

2.0.0

19 Jan 23:31
8b441f3

Choose a tag to compare

this release adds support for roundtripping floating point values such as Double, Float, Float16, and on supported platforms, Float80.

New Contributors

Full Changelog: 1.2.0...2.0.0

1.2.0

23 Jan 01:21
a349369

Choose a tag to compare

This release adds an initializer JSON.Node.init(parsingFragment:) that accepts any JSON value (including leaf nodes) instead of just Arrays and Objects.

Full Changelog: 1.1.2...1.2.0

1.1.2

16 Jan 00:19
264cb5b

Choose a tag to compare

This release upgrades the package’s swift-grammar dependency.

For SwiftPM users, this has the practical effect of freeing the package of a transitive swift-atomics dependency, although the actual library targets in this package never even depended on swift-atomics in the first place, and that repository would only be cloned due to SwiftPM’s strange insistence on speculatively downloading all GitHub dependencies discoverable from the root manifest.

Full Changelog: 1.1.1...1.1.2

1.1.1

02 Oct 22:57

Choose a tag to compare

This release drops the package’s swift-testing dependency (as Testing now ships with the toolchain), and in turn frees it of its transitive swift-syntax dependency. It contains no functional changes to the library, but restores the ability to build the package as a whole (including tests) for CI purposes using a Swift 6 toolchain.

Full Changelog: 1.1.0...1.1.1

1.1.0

24 May 02:17

Choose a tag to compare

This release adds JSONEncodable conformances for Array and ArraySlice.

1.0.1

22 Apr 21:42

Choose a tag to compare

This release updates the swift-grammar (0.4) and swift-testing (0.7) dependencies to their next minors, to unblock anyone currently stuck in dependency hell due to one or both of those packages.

1.0.0

15 Mar 22:14

Choose a tag to compare

Swift JSON is a Foundation-free JSON parser and encoder written in pure Swift. It is designed to be performant, expressive, and speedy to compile.

Swift JSON builds on linux and macOS. As of version 1.0.0, it requires Swift 5.10 or newer.

You can get started with Swift JSON by reading its documentation, or by following the tutorial.

0.3.0

29 Aug 18:51
3f62c13

Choose a tag to compare

swift-json v0.3.0 is finally here!

obsoleting json dictionary representations

version 0.2 of swift-json modeled objects (things written in curly braces {}) as dictionaries of String keys and JSON values:

case array([Self])
case object([String: Self])

this is the most obvious representation for a JSON value, it’s convenient for many use cases, and it dovetails nicely with the JSON.array(_:) enumeration case. however, this representation also comes with some functional and performance issues, so we have replaced this representation with a array-based [(key:String, value:JSON)] representation. this matches APIs vended by Dictionary itself.

case object([(key:String, value:Self)])

to convert an object to a Dictionary, use one of the as(_:uniquingKeysWith:) methods on JSON.

ergonomics for high-performance decoding APIs

previously, users of swift-json had to choose between a slow but ergonomic Decodable-based API, and a fast but extremely verbose direct decoding API. swift-json v0.3 comes with a much more ergonomic API for high-performance decoding.

to decode objects, you can now use the LintingDictionary abstraction, and to decode arrays, you can now use swift-json’s Array extensions. in addition to being faster, using these decoding interfaces also gives better error diagnostics when decoding fails.

for an example of how to use LintingDictionary, see its associated snippet.

RawRepresentable convenience APIs

swift-json v0.3 comes with a handful of new convenience APIs for decoding RawRepresentable types directly from JSON messages:

func `as`<StringCoded>(cases: StringCoded.Type) throws -> StringCoded

func `as`<CharacterCoded>(cases: CharacterCoded.Type) throws -> CharacterCoded

func `as`<ScalarCoded>(cases: ScalarCoded.Type) throws -> ScalarCoded

func `as`<IntegerCoded>(cases: IntegerCoded.Type) throws -> IntegerCoded

func `as`<UnsignedIntegerCoded>(cases: UnsignedIntegerCoded.Type) throws -> UnsignedIntegerCoded

avoid working with swift-grammar directly

version 0.2 of swift-json re-exported Grammar’s entire API, and expected users to invoke swift-grammar parsing rules directly. this was done to reduce the amount of “magic” in the parser, and guide users towards the lowest-overhead parsing configurations needed for their use case, which was important back when swift-json was a closed-source library primarily used for fintech applications. however it also made for a very complex API that was hard to learn if you were not already familiar with how swift-grammar works.

version 0.3 of swift-json now comes with a simplified init(parsing:) initializer, which takes UTF-8-encoded input, and just “does the right thing” by default.

ExpressibleBy_Literal conformances

the JSON type now conforms to ExpressibleByArrayLiteral,ExpressibleByBooleanLiteral, ExpressibleByDictionaryLiteral, ExpressibleByExtendedGraphemeClusterLiteral, ExpressibleByStringLiteral, and ExpressibleByUnicodeScalarLiteral.

platform and toolchain support

swift-json supports swift 5.3 ... 5.8 nightly, and has official CI coverage for linux, macOS, iOS, watchOS, tvOS, and windows.

swift-json has a fully-green build matrix on the swift package index.

documentation

we have expanded swift-json’s documentation, and published it on swiftinit.