https://github.com/gd-personal/flexi-json
A ruby gem designed for manipulating JSON data
https://github.com/gd-personal/flexi-json
json json-data ruby-gem rubygem rubygems
Last synced: 4 months ago
JSON representation
A ruby gem designed for manipulating JSON data
- Host: GitHub
- URL: https://github.com/gd-personal/flexi-json
- Owner: GD-Personal
- License: mit
- Created: 2024-09-19T08:09:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-28T18:59:15.000Z (over 1 year ago)
- Last Synced: 2025-12-01T13:20:00.290Z (6 months ago)
- Topics: json, json-data, ruby-gem, rubygem, rubygems
- Language: Ruby
- Homepage:
- Size: 75.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[](https://rubygems.org/gems/flexi-json)
[](https://github.com/GD-Personal/flexi-json/actions)
[](https://codeclimate.com/github/GD-Personal/flexi-json/maintainability)
[](https://codeclimate.com/github/GD-Personal/flexi-json/test_coverage)
# flexi-json
`Flexi::Json` is a versatile Ruby gem designed for manipulating JSON data. With functionalities for searching, generating new JSON, and transforming existing structures.
## Installation
You can install the gem using RubyGems:
```
gem install flexi-json
```
or add it to your Gemfile
```
gem 'flexi-json'
```
and then run:
```
bundle install
```
## Usage
```ruby
require 'flexi/json'
# Load a raw json data
flexi_json = Flexi::Json.new("{\"name\":\"John\",\"address\":\"Sydney Australia\"}")
# => "John", :address=>"Sydney Australia"}, @name="John", @searchable_fields=["name", "address"]>]>
# Load a json data from a local file
flexi_json = Flexi::Json.new("some/path/to/file.json")
# Load a json data from a url
flexi_json = Flexi::Json.new("https://raw.githubusercontent.com/GD-Personal/flexi-json/main/spec/data/dataset.json")
# Search for data
flexi_json.search("john")
# => [#"John", :address=>"Sydney Australia"}, @name="John", @searchable_fields=["name", "address"]>]
# Or filter it by your chosen key e.g first_name
flexi_json.search("john", "first_name")
flexi_json.search("john", "first_name,email")
# Find duplicate emails
flexi_json.find_duplicates("email")
flexi_json.find_duplicates("email,full_name")
```
## Advanced search
```ruby
search_query = {first_name: "john", address: "sydney"}
flexi_json.search(
search_query,
options: {matched_all: true, exact_match: false}
)
# => [#"John", :address=>"Sydney Australia"}, @name="John", @searchable_fields=["name", "address"]>]
```
## Configuration
```ruby
Flexi::Json.configure do |config|
config.exact_match_search = true
config.match_all_fields = true
end
```
## TODOS
- Generate results in json, csv, txt, or output in the console
- Add CRUD support to the dataset
- Optimise the search function by implementing indeces
- Optimise the loader by chunking the data
## Contributing
Contributions are welcome! If you have suggestions for improvements or new features, feel free to fork the repository and create a pull request. Please ensure your code adheres to the project's coding standards and includes tests for new features.
Bug reports and pull requests are welcome on GitHub at https://github.com/GD-Personal/flexi-json. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/GD-Personal/flexi-json/blob/main/CODE_OF_CONDUCT.md).
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).