https://github.com/wintercore/jsonerino
Another JSON parser written from scratch in Ruby
https://github.com/wintercore/jsonerino
cli json parser ruby
Last synced: 10 days ago
JSON representation
Another JSON parser written from scratch in Ruby
- Host: GitHub
- URL: https://github.com/wintercore/jsonerino
- Owner: WinterCore
- Created: 2020-06-24T17:10:43.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-23T21:10:46.000Z (almost 3 years ago)
- Last Synced: 2025-04-06T04:16:15.273Z (about 1 year ago)
- Topics: cli, json, parser, ruby
- Language: Ruby
- Homepage: https://rubygems.org/gems/jsonerino
- Size: 169 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSONERINO
JSONERINO is a lightweight json parser written in ruby. with no dependencies. It also contains a command line tool for validating json files (check below).
## Usage
First of all you need to add the following to your `Gemfile`
```
gem 'jsonerino'
```
Then you need to run `bundle install`.
After that you can use it to parse json by calling the `parse` method
```ruby
require 'jsonerino'
p Jsonerino::parse('nil') == nil # true
output = Jsonerino::parse('[{"name" : "Alex", "age" : 15 }]')
p output == [{"name" => "Alex","age" => 15}] # true
```
Calling the `parse` method will convert the json string to it's corresponding ruby representation.
[](https://repl.it/@WinterCore/microverse-ruby-capstone-json-parser#main.rb)
## Using the included json validator

- Run `gem install jsonerino`
- Run `jsonerino `
If no filename is provided. jsonerino will try to parse all the JSON files that are in your current working directory.
## Invalid JSON Examples
```json
{ "foo: true }
```
Will throw "End of data reached while reading JSON contents" error. Because the parser will interpret everything after the first double quotes character as a string and it continues reading until it finds a closing double quotes. But in this case it doesn't which is why an error is thrown.
```json
{ "hey": foo }
```
Will throw "Unexpected token foo". Because foo is an unkown identifier. The allowed identifiers in JSON are `true`, `false`, and `null`. And in this case the error can be fixed by wrapping it in a string.
## Built with
- Ruby
## Development Commands
- Run tests `bundle exec rspec`
- Run rubocop (code linter) `bundle exec rubocop`
Note: Make sure to run `bundle install` in the project's directory before trying to run the previous commands.
## Authors
👤 **WinterCore**
- Github: [@WinterCore](https://github.com/WinterCore)
## 🤝 Contributing
Contributions, issues and feature requests are welcome! Start by:
- Forking the project
- Cloning the project to your local machine
- `cd` into the project directory
- Run `git checkout -b your-branch-name`
- Make your contributions
- Push your branch up to your forked repository
- Open a Pull Request with a detailed description to the development branch of the original project for a review
## Show your support
Give a ⭐️ if you like this project!