All Projects → javerous → SMJJSONPath

javerous / SMJJSONPath

Licence: Apache-2.0 License
JSONPath implementation in Objective-C

Programming Languages

objective c
16641 projects - #2 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to SMJJSONPath

Apple-Platform-Security-Guides
Every Apple Platform Security Guide
Stars: ✭ 106 (+278.57%)
Mutual labels:  tvos, watchos
Hostess.swift
A Swift implementation of NSHost that works on iOS, OS X and tvOS. Hostess.swift is safe to use in a framework because it does not require a bridging header. Hostess is Swift 4.0 (or newer) only and replaces the Swift 2.x only Host.swift.
Stars: ✭ 27 (-3.57%)
Mutual labels:  tvos, watchos
Mechanica
A cross-platform library of Swift utils to ease your iOS | macOS | watchOS | tvOS and Linux development.
Stars: ✭ 27 (-3.57%)
Mutual labels:  tvos, watchos
PotentCodables
🧪 PotentCodables - A potent set of implementations and extensions to the Swift Codable system
Stars: ✭ 32 (+14.29%)
Mutual labels:  tvos, watchos
ios-watchos-tvos-macos-resources
Updated list of Swift frameworks and libraries for iOS, watchOS, tvOS and macOS.
Stars: ✭ 58 (+107.14%)
Mutual labels:  tvos, watchos
Johnny
Melodic Caching for Swift
Stars: ✭ 36 (+28.57%)
Mutual labels:  tvos, watchos
OpenAPI-ObjectiveC
KKBOX Open API Developer SDK for iOS/macOS/watchOS/tvOS
Stars: ✭ 19 (-32.14%)
Mutual labels:  tvos, watchos
lisk-swift
Swift 4 library for Lisk - Including Local Signing for maximum security
Stars: ✭ 13 (-53.57%)
Mutual labels:  tvos, watchos
swift-standard-clients
Client declarations and live implementations for standard iOS managers
Stars: ✭ 28 (+0%)
Mutual labels:  tvos, watchos
CombineCoreBluetooth
A wrapper API for CoreBluetooth using Combine Publishers
Stars: ✭ 50 (+78.57%)
Mutual labels:  tvos, watchos
SwiftRadix
Easily convert integers to binary/hex/octal strings and back again with clean functional syntax.
Stars: ✭ 34 (+21.43%)
Mutual labels:  tvos, watchos
TermiNetwork
🌏 A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications.
Stars: ✭ 80 (+185.71%)
Mutual labels:  tvos, watchos
SeedTruck
Torrent management app for iOS, macOS, tvOS and watchOS made in SwiftUI 2. Same codebase for all platforms!
Stars: ✭ 25 (-10.71%)
Mutual labels:  tvos, watchos
BlockiesSwift
Unique blocky identicons generator for Swift
Stars: ✭ 53 (+89.29%)
Mutual labels:  tvos, watchos
stinsen
Coordinators in SwiftUI. Simple, powerful and elegant.
Stars: ✭ 563 (+1910.71%)
Mutual labels:  tvos, watchos
Columbus
A feature-rich country picker for iOS, tvOS and watchOS.
Stars: ✭ 23 (-17.86%)
Mutual labels:  tvos, watchos
IrregularGradient
Create animated irregular gradients in SwiftUI.
Stars: ✭ 127 (+353.57%)
Mutual labels:  tvos, watchos
Dots
Lightweight Concurrent Networking Framework
Stars: ✭ 35 (+25%)
Mutual labels:  tvos, watchos
Jsonify
♨️A delightful JSON parsing framework.
Stars: ✭ 42 (+50%)
Mutual labels:  tvos, watchos
Wells
A lightweight diagnostics report submission system
Stars: ✭ 26 (-7.14%)
Mutual labels:  tvos, watchos

SMJJSONPath

SMJJSONPath is a complete JSONPath implementation written in Objective-C. It's a wide adaptation of Jayway JsonPath implementation.

Overview

It supports a wide bunch of functionalities:

  • dot and square bracket syntax
  • inline predicates
  • functions
  • nesting

You can take a look to the Jayway JsonPath documentation for more information.

Adaptation

This implementation is a tight adaptation of Jayway JsonPath. It respects the original structure and naming, as much as possible. The changes are mainly to be more Objective-C stylized (named parameters, use NSError instead of try-catch-exception, etc.).

This tight adaptation was done for different reasons:

  • If I wanted to structure something from my own view, I would have started from scratch, and I wouldn't have done it at all : this is a big bunch of code, tests and reflexion to do, more than I want to give to that.
  • The Jayway JsonPath project have a pretty good and complete implementation (with some cleaning here and there to do, which are already documented by original developers). It's a good reference, from my point of view.
  • I want to facilitate cherry-picking updates from Jayway JsonPath to include them right here.

This code is currently in sync with the source code in commit 00cfce3.

Query

Simple example:

// Create a SMJJSONPath object
SMJJSONPath *jsonPath = [[SMJJSONPath alloc] initWithJSONPathString:@"$.books..author" error:&error];

// Create a configuration.
SMJConfiguration *configuration = [SMJConfiguration defaultConfiguration];

// Query a JSON document.
NSArray *result = [jsonPath resultForJSONFile:fileURL configuration:configuration error:&error];

// That's all.

Update

You can update a JSON mutable object accordingly to a JSONPath:

// Create a SMJJSONPath object
SMJJSONPath *jsonPath = [[SMJJSONPath alloc] initWithJSONPathString:@"$.books..author" error:&error];

// Create a configuration.
SMJConfiguration *configuration = [SMJConfiguration defaultConfiguration];

// Read a JSON document with mutable containers.
id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];

// Update the json.
[jsonPath updateJSONMutableObject:jsonObject deleteWithConfiguration:configuration error:&error];


// The queried path was deleted in jsonObject.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].