3.0.0 #61
tayloraswift
announced in
Announcements
3.0.0
#61
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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 ofString
keys andJSON
values: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.to convert an object to a
Dictionary
, use one of theas(_:uniquingKeysWith:)
methods onJSON
.ergonomics for high-performance decoding APIs
previously, users of
swift-json
had to choose between a slow but ergonomicDecodable
-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 useswift-json
’sArray
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 APIsswift-json
v0.3 comes with a handful of new convenience APIs for decodingRawRepresentable
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
directlyversion 0.2 of
swift-json
re-exportedGrammar
’s entire API, and expected users to invokeswift-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 whenswift-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 howswift-grammar
works.version 0.3 of
swift-json
now comes with a simplifiedinit(parsing:)
initializer, which takes UTF-8-encoded input, and just “does the right thing” by default.ExpressibleBy_Literal
conformancesthe
JSON
type now conforms toExpressibleByArrayLiteral
,ExpressibleByBooleanLiteral
,ExpressibleByDictionaryLiteral
,ExpressibleByExtendedGraphemeClusterLiteral
,ExpressibleByStringLiteral
, andExpressibleByUnicodeScalarLiteral
.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.This discussion was created from the release 3.0.0.
Beta Was this translation helpful? Give feedback.
All reactions