Skip to content

luckymarmot/jqKit

Repository files navigation

jqKit

An Objective-C wrapper for jqlib, the C library behind jq (a lightweight and flexible JSON processor).

⚠️ Works only on macOS 10.10+

Installation

Via Cocoapods:

pod 'macOSjqKit'

Usage

NSString* program = @"."; // the jq filter
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:@{@"foo":@0, @"bar":@42} options:kNilOptions error:NULL];

// filter
NSArray<NSData*>* results = [LMJqFilter filterWithProgram:program data:jsonData error:NULL];

// enumerate the results
[results enumerateObjectsUsingBlock:^(NSData * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
    NSLog(@"result = %@", [[NSString alloc] initWithData:obj encoding:NSUTF8StringEncoding]);
}];

Development

Build libjq and oniguruma

make

Influences

License

Copyright 2019 Paw. MIT License.