https://github.com/chef/ffi-yajl
Ruby FFI gem wrapper around yajl2 library
https://github.com/chef/ffi-yajl
Keywords from Contributors
chef configuration-management discovery ohai deployment cfgmgt rubygems activerecord mvc ruby-gem
Last synced: about 17 hours ago
JSON representation
Repository metadata
Ruby FFI gem wrapper around yajl2 library
- Host: GitHub
- URL: https://github.com/chef/ffi-yajl
- Owner: chef
- License: mit
- Created: 2013-10-24T06:16:58.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2026-05-15T13:24:46.000Z (8 days ago)
- Last Synced: 2026-05-16T01:45:18.104Z (8 days ago)
- Language: Ruby
- Size: 788 KB
- Stars: 12
- Watchers: 12
- Forks: 24
- Open Issues: 7
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
README.md
FFI YAJL
ffi-yajl is a Ruby adapter for the yajl JSON parser/generator library. ffi-yajl supports multiple Ruby C extension mechanisms, including both MRI native extensions and FFI in order to be compatible with as many Ruby implementations as possible while providing good performance where possible.
How to Install
Warning if building through Omnibus, a preinstalled ffi-yajl and libyajl2-gem version not matching the bundled version of the project you're attempting to build (e.g., Chef) may cause:
cannot find -lyajldll: No such file or directory
If your build script ends up up in this state, a short term fix is gem uninstall -I libyajl2 before the failing bundle install
Install from the command-line:
gem install ffi-yajl
Or use a Gemfile:
gem 'ffi-yajl'
Supported Ruby VMs:
- Ruby 2.2+ and compatible rbx or jruby
Supported Distros:
- Ubuntu 10.04 through 14.10
- Debian 7.x
- RHEL/CentOS/Oracle 5.x/6.x/7.x
- Solaris 9/10/11 (gcc, sun compiler untested)
- AIX 6.x/7.x (gcc or xlc)
- Windows 2008r2/2012 (and Win2k/2k3 and consumer versions should work)
Basic Usage
Start by requiring it:
require 'ffi_yajl'
You can encode and parse with class objects:
options_hash = {}
json = FFI_Yajl::Encoder.encode( {"foo"=>["bar","baz"]}, options_hash )
hash = FFI_Yajl::Parser.parse( json, options_hash )
Or you can be more object oriented:
options_hash = {}
encoder = FFI_Yajl::Encoder.new( options_hash )
json = encoder.encode( {"foo"=>["bar","baz"]} )
parser = FFI_Yajl::Parser.new( options_hash )
hash = parser.parse( json )
Parser Options
:check_utf8:dont_validate_strings:symbolize_keys(default = false): JSON keys are parsed into symbols instead of strings.:symbolize_names(default = false): Alias for:symbolize_keys.:allow_trailing_garbage:allow_multiple_values:allow_partial_values:unique_key_checking(default = false): Will raise an exception if keys are repeated in hashes in the input JSON. Without this, repeated keys will silently replace the previous key.
Encoder Options
:pretty(default = false): Produces more human readable 'pretty' output.:validate_utf8(default = true): Will raise an exception when trying to encode strings that are invalid UTF-8. When set to false this still will produce valid UTF-8 JSON but will replace invalid characters.
Forcing FFI or C Extension
You can set the environment variable FORCE_FFI_YAJL to ext or ffi to control if the C extension or FFI bindings are used.
Yajl Library Packaging
This library prefers to use the embedded yajl 2.x C library packaged in the libyajl2 gem. In order to use the operating system yajl library (which must be yajl 2.x) the environment variable USE_SYSTEM_LIBYAJL2 can be set before installing or bundling libyajl2. This will force the libyajl2 gem to skip compiling its embedded library and the ffi-yajl gem will fallback to using the system yajl library.
No JSON Gem Compatiblity layer
This library does not offer a feature to patch #to_json methods into all the ruby classes similarly to the JSON gem or yajl-ruby's yajl/json_gem compatibility API. The differences in encoding between the JSON gem and the Yajl C library can produce different output on different systems and makes testing brittle. Such a feature will not be included. It was removed in this pull request and could be easily extracted to its own gem (we have no interest in maintaining that gem):
https://github.com/chef/ffi-yajl/pull/47/files
Why This Instead of X?
yajl is the only JSON library we've found that has error messages that meet our requirements. The stdlib json gem and oj (at the time we started this project) have error messages like "invalid token at byte 1234," which are probably fine for server use, but in chef we frequently deal with user-written JSON documents, which means we need a good user experience when encountering malformed JSON.
We previously used brianmario's yajl-ruby project, but we wanted to be able to fallback to using FFI bindings to the C code (so we could support non-MRI rubies) and we also needed some bug fixes in yajl2, but the maintainer wasn't able to devote enough time to the project to make these updates in a timeframe that worked for us.
Thanks
This was initially going to be a clean rewrite of an ffi ruby wrapper around yajl2, but as it progressed more and more code was pulled in from brianmario's existing yajl-ruby gem, particularly all the c extension code, lots of specs and the benchmarks. And the process of writing this would have been much more difficult without being able to draw heavily from already solved problems in yajl-ruby.
License
Given that this draws heavily from the yajl-ruby sources, and could be considered a derivative work, the MIT License from that project has been preserved and this source code has deliberately not been dual licensed under Chef's typical Apache License. See the LICENSE file in this project.
Owner metadata
- Name: Progress Chef
- Login: chef
- Email: ops@chef.io
- Kind: organization
- Description:
- Website: https://www.chef.io/
- Location: United States of America
- Twitter: chef
- Company:
- Icon url: https://avatars.githubusercontent.com/u/29740?v=4
- Repositories: 245
- Last ynced at: 2023-04-10T00:51:04.360Z
- Profile URL: https://github.com/chef
GitHub Events
Total
- Delete event: 4
- Pull request event: 15
- Fork event: 3
- Issues event: 2
- Watch event: 2
- Issue comment event: 13
- Push event: 35
- Pull request review comment event: 2
- Pull request review event: 17
- Create event: 10
Last Year
- Delete event: 4
- Pull request event: 12
- Fork event: 1
- Issues event: 2
- Issue comment event: 10
- Push event: 25
- Pull request review event: 11
- Create event: 7
Committers metadata
Last synced: 2 days ago
Total Commits: 584
Total Committers: 31
Avg Commits per committer: 18.839
Development Distribution Score (DDS): 0.195
Commits in past year: 37
Committers in past year: 11
Avg Commits per committer in past year: 3.364
Development Distribution Score (DDS) in past year: 0.568
| Name | Commits | |
|---|---|---|
| Lamont Granquist | l****t@s****g | 470 |
| Chef Expeditor | c****i@c****o | 23 |
| Tim Smith | t****h@c****o | 18 |
| Jaymala Sinha | j****a@c****o | 8 |
| Thomas Powell | t****l@p****m | 8 |
| skeshari12 | s****i@m****m | 7 |
| Stan Hu | s****u@g****m | 6 |
| Kouhei Sutou | k****u@c****m | 5 |
| Olle Jonsson | o****n@g****m | 4 |
| tyler-ball | t****l@g****m | 4 |
| Chef Expeditor | e****r@c****o | 3 |
| cgunasree08 | C****e@p****m | 3 |
| Elan Ruusamäe | g****n@d****e | 2 |
| Jason Potkanski | e****n@y****m | 2 |
| Marc A. Paradise | m****e@g****m | 2 |
| Rishi Kumar Chawda | r****a | 2 |
| Tyler Vann-Campbell | t****r@b****m | 2 |
| danielsdeleo | d****n@c****o | 2 |
| Aaron Lasseigne | a****e@g****m | 1 |
| Jason Kulatunga | j****n@t****m | 1 |
| John McCrae | j****e@p****m | 1 |
| Lance Albertson | l****e@o****g | 1 |
| Lennart Brinkmann | l****a@g****m | 1 |
| Nandan Hegde | 2****3 | 1 |
| Phil Dibowitz | p****l@i****m | 1 |
| Sean Simmons | s****s@p****m | 1 |
| Thom May | t****m@m****t | 1 |
| Vít Ondruch | v****h@r****m | 1 |
| brianLoomis | l****s@p****m | 1 |
| chef-expeditor[bot] | 4****] | 1 |
| and 1 more... | ||
Committer domains:
- progress.com: 5
- chef.io: 5
- redhat.com: 1
- may.lt: 1
- ipom.com: 1
- osuosl.org: 1
- thesparktree.com: 1
- buddy.com: 1
- delfi.ee: 1
- clear-code.com: 1
- msystechnologies.com: 1
- scriptkiddie.org: 1
Issue and Pull Request metadata
Last synced: 8 days ago
Total issues: 42
Total pull requests: 87
Average time to close issues: 2 months
Average time to close pull requests: about 1 month
Total issue authors: 31
Total pull request authors: 29
Average comments per issue: 1.86
Average comments per pull request: 1.46
Merged pull request: 64
Bot issues: 2
Bot pull requests: 0
Past year issues: 2
Past year pull requests: 17
Past year average time to close issues: about 2 months
Past year average time to close pull requests: about 1 month
Past year issue authors: 2
Past year pull request authors: 9
Past year average comments per issue: 1.5
Past year average comments per pull request: 0.06
Past year merged pull request: 8
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- lamont-granquist (10)
- dependabot-preview[bot] (2)
- h4ck3rm1k3 (2)
- crsuarez (1)
- anupamkakade (1)
- DavidTNguyen (1)
- tas50 (1)
- juliandunn (1)
- AnalogJ (1)
- cwimmer (1)
- logicminds (1)
- ddpdevang (1)
- adamedx (1)
- hsbt (1)
- iongion (1)
Top Pull Request Authors
- lamont-granquist (28)
- tas50 (5)
- kou (4)
- jaymalasinha (4)
- cgunasree08 (4)
- steakknife (3)
- olleolleolle (3)
- rishichawda (3)
- stanhu (3)
- tpowell-progress (3)
- dafyddcrosby (2)
- clintoncwolfe (2)
- sean-sype-simmons (2)
- danielsdeleo (2)
- voxik (2)
Top Issue Labels
- Type: Bug (11)
- Type: Enhancement (6)
- Status: Untriaged (5)
- Triage: Duplicate (2)
Top Pull Request Labels
- oss-standards (5)
- Expeditor: Skip All (4)
- Expeditor: Bump Version Minor (4)
- Triage: Duplicate (2)
- ai-assisted (1)
- do not merge (1)
Package metadata
- Total packages: 12
-
Total downloads:
- rubygems: 110,201,725 total
- Total docker downloads: 873,688,096
- Total dependent packages: 29 (may contain duplicates)
- Total dependent repositories: 2,315 (may contain duplicates)
- Total versions: 170
- Total maintainers: 5
gem.coop: ffi-yajl
Ruby FFI wrapper around YAJL 2.x
- Homepage: http://github.com/chef/ffi-yajl
- Documentation: http://www.rubydoc.info/gems/ffi-yajl/
- Licenses: MIT
- Latest release: 3.0.0 (published almost 3 years ago)
- Last Synced: 2026-05-21T14:00:30.938Z (2 days ago)
- Versions: 79
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 55,103,842 Total
- Docker Downloads: 436,844,048
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.16%
- Downloads: 0.48%
- Maintainers (5)
rubygems.org: ffi-yajl
Ruby FFI wrapper around YAJL 2.x
- Homepage: http://github.com/chef/ffi-yajl
- Documentation: http://www.rubydoc.info/gems/ffi-yajl/
- Licenses: MIT
- Latest release: 3.0.0 (published almost 3 years ago)
- Last Synced: 2026-05-21T03:02:30.061Z (3 days ago)
- Versions: 81
- Dependent Packages: 29
- Dependent Repositories: 2,315
- Downloads: 55,097,883 Total
- Docker Downloads: 436,844,048
-
Rankings:
- Docker downloads count: 0.332%
- Downloads: 0.502%
- Dependent repos count: 0.655%
- Dependent packages count: 0.803%
- Average: 3.989%
- Forks count: 5.898%
- Stargazers count: 15.74%
- Maintainers (5)
debian-11: ruby-ffi-yajl
- Homepage: https://github.com/chef/ffi-yajl
- Documentation: https://packages.debian.org/bullseye/ruby-ffi-yajl
- Licenses:
- Latest release: 2.3.1-3 (published 3 months ago)
- Last Synced: 2026-03-13T08:29:30.436Z (2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-10: ruby-ffi-yajl
- Homepage: http://github.com/chef/ffi-yajl
- Documentation: https://packages.debian.org/buster/ruby-ffi-yajl
- Licenses:
- Latest release: 2.3.1-1 (published 3 months ago)
- Last Synced: 2026-03-13T19:03:40.567Z (2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.04: ruby-ffi-yajl
- Homepage: https://github.com/chef/ffi-yajl
- Licenses:
- Latest release: 2.3.1-3build4 (published 3 months ago)
- Last Synced: 2026-03-11T07:10:25.195Z (2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-22.04: ruby-ffi-yajl
- Homepage: https://github.com/chef/ffi-yajl
- Licenses:
- Latest release: 2.3.1-3build2 (published 3 months ago)
- Last Synced: 2026-03-13T22:41:59.328Z (2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.10: ruby-ffi-yajl
- Homepage: https://github.com/chef/ffi-yajl
- Licenses:
- Latest release: 2.3.1-3build4 (published 3 months ago)
- Last Synced: 2026-03-14T03:13:37.020Z (2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-24.10: ruby-ffi-yajl
- Homepage: https://github.com/chef/ffi-yajl
- Licenses:
- Latest release: 2.3.1-3build7 (published 3 months ago)
- Last Synced: 2026-03-09T17:05:25.580Z (3 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-12: ruby-ffi-yajl
- Homepage: https://github.com/chef/ffi-yajl
- Documentation: https://packages.debian.org/bookworm/ruby-ffi-yajl
- Licenses:
- Latest release: 2.3.1-3 (published 3 months ago)
- Last Synced: 2026-03-13T03:29:16.064Z (2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-24.04: ruby-ffi-yajl
- Homepage: https://github.com/chef/ffi-yajl
- Licenses:
- Latest release: 2.3.1-3build6 (published 4 months ago)
- Last Synced: 2026-03-06T15:58:56.828Z (3 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-13: ruby-ffi-yajl
- Homepage: https://github.com/chef/ffi-yajl
- Documentation: https://packages.debian.org/trixie/ruby-ffi-yajl
- Licenses:
- Latest release: 2.3.1-3 (published 3 months ago)
- Last Synced: 2026-03-14T18:09:09.836Z (2 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- chefstyle >= 0 development
- ffi >= 0 development
- pry ~> 0.9 development
- rack >= 0 development
- rake >= 0 development
- rake-compiler >= 0 development
- rspec >= 0 development
- actions/checkout v4 composite
- r7kamura/rubocop-problem-matchers-action v1 composite
- ruby/setup-ruby v1 composite
- actions/checkout v2 composite
- ruby/setup-ruby v1 composite
- cookstyle ~> 8.1 development
- libyajl2 >= 2.1
- yajl >= 0
Score: 27.08545355751573