{"id":21199187,"url":"https://github.com/r167/jsonw","last_synced_at":"2025-10-26T12:48:33.900Z","repository":{"id":39741539,"uuid":"143318965","full_name":"R167/jsonw","owner":"R167","description":"Example JSON gem for personal testing","archived":false,"fork":false,"pushed_at":"2022-05-26T18:59:43.000Z","size":18,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T14:46:50.651Z","etag":null,"topics":["example","json","ruby-gem"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/R167.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-02T16:21:20.000Z","updated_at":"2018-08-02T23:17:16.000Z","dependencies_parsed_at":"2022-08-28T06:35:09.000Z","dependency_job_id":null,"html_url":"https://github.com/R167/jsonw","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R167%2Fjsonw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R167%2Fjsonw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R167%2Fjsonw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/R167%2Fjsonw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/R167","download_url":"https://codeload.github.com/R167/jsonw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243653484,"owners_count":20325749,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["example","json","ruby-gem"],"created_at":"2024-11-20T19:59:38.219Z","updated_at":"2025-10-26T12:48:33.829Z","avatar_url":"https://github.com/R167.png","language":"Ruby","readme":"# JsonW\n\nFor a while now, I've always enjoyed looking at the simplicity of the [JSON spec](http://www.json.org/)\nand always had a nagging feeling that I wanted to try implementing it. Lately, for one reason or another,\nI've been looking at other Ruby JSON implementations such as [Yajl](https://github.com/brianmario/yajl-ruby),\n[Oj](https://github.com/ohler55/oj), Ruby's [JSON](https://github.com/flori/json) implementation, and\n[Fast JSON API](https://github.com/Netflix/fast_jsonapi), as well as [MessagePack](https://github.com/msgpack/msgpack-ruby).\n\nTL;DR: I got bored so I decided to try my hand at implementing a standard like this from the provided\nspec and see how I did. Additionally, I'm looking at it as a learning opportunity for implementing a (planned)\nversion in C or Rust: creating a gem with native extensions.\n\nLong Story short: this is all more of a learning exercise than anything else. Don't expect the code to\nbe perfect or even think it's a good idea to use it, but if you're curious, feel free to have a look around.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'jsonw'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install jsonw\n\n## Usage\n\nThe gem currently has no options, though the simplest way to use it at the moment is:\n\n```ruby\n# Generating JSON\nJsonW.dump({author: \"Winston\", \"numbers\" =\u003e [1, 2, 3/4r, 7.5]})\n# =\u003e '{\"author\":\"Winston\",\"numbers\":[1,2,\"3\\/4\",7.5]}'\n\n# Parsing JSON\nJsonW.parse('{\"author\":\"Winston\",\"numbers\":[1,2,\"3\\/4\",7.5]}')\n# =\u003e {\"author\"=\u003e\"Winston\", \"numbers\"=\u003e[1, 2, \"3/4\", 7.5]}\n```\n\n## Speed Results\n\nRunning some basic specs from `bin/json_comp.rb`, the parsing is... passable (about 3.5x slower than `JSON::Pure`),\nespecially considering it's a fairly naive approach in Ruby. Generating isn't overall too bad though (about 2x slower\nthan compiled `JSON` due to certain optimizations of only calling `#to_json` when no other choice).\n\nParsing:\n```\nBenchmarking parsing a 18254 byte JSON doc\nWarming up --------------------------------------\n               JsonW    10.000  i/100ms\n                JSON   190.000  i/100ms\n          JSON::Pure    23.000  i/100ms\n                Yajl   259.000  i/100ms\n                  Oj   463.000  i/100ms\nCalculating -------------------------------------\n               JsonW     93.446  (± 4.3%) i/s -    470.000  in   5.040820s\n                JSON      2.725k (± 6.4%) i/s -     13.680k in   5.042823s\n          JSON::Pure    256.247  (± 2.7%) i/s -      1.288k in   5.030124s\n                Yajl      3.002k (± 2.6%) i/s -     15.022k in   5.007733s\n                  Oj      5.370k (± 1.8%) i/s -     26.854k in   5.002415s\n\nComparison:\n                  Oj:     5369.9 i/s\n                Yajl:     3001.8 i/s - 1.79x  slower\n                JSON:     2725.2 i/s - 1.97x  slower\n          JSON::Pure:      256.2 i/s - 20.96x  slower\n               JsonW:       93.4 i/s - 57.47x  slower\n```\n\nDumping:\n```\nBenchmarking generating a 18254 byte JSON doc\nWarming up --------------------------------------\n               JsonW   143.000  i/100ms\n                JSON   291.000  i/100ms\n          JSON::Pure    39.000  i/100ms\n                Yajl   710.000  i/100ms\n                  Oj     1.438k i/100ms\nCalculating -------------------------------------\n               JsonW      1.479k (± 2.2%) i/s -      7.436k in   5.028877s\n                JSON      5.338k (± 2.1%) i/s -     26.772k in   5.017948s\n          JSON::Pure    434.372  (± 2.5%) i/s -      2.184k in   5.031419s\n                Yajl      6.534k (± 6.2%) i/s -     32.660k in   5.019365s\n                  Oj     14.995k (± 5.3%) i/s -     74.776k in   5.002104s\n\nComparison:\n                  Oj:    14994.8 i/s\n                Yajl:     6533.8 i/s - 2.29x  slower\n                JSON:     5337.6 i/s - 2.81x  slower\n               JsonW:     1479.4 i/s - 10.14x  slower\n          JSON::Pure:      434.4 i/s - 34.52x  slower\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/R167/jsonw. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the JsonW project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/R167/jsonw/blob/master/CODE_OF_CONDUCT.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr167%2Fjsonw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr167%2Fjsonw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr167%2Fjsonw/lists"}