json-repair 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17c6b285b495a3c053ae838e701205ec682f7648856cadb52d00da5d348f393c
4
- data.tar.gz: 644acd7c8840e0a1edf4399297c1bbcc17739cdd13ab6ee9102880981a00bc84
3
+ metadata.gz: b50bffd203f06c7b7d2fa875802b66dd6fc944d01fe7c7f6c349233b2dc73d60
4
+ data.tar.gz: f018489c9572a61a72e9784af8f2b2fec335e215933ad0efea1265cff7d7be4e
5
5
  SHA512:
6
- metadata.gz: 6bbe9f8d1e5558ab344987a867dc1aae6859c7e33b537cf20b78d97b5db4734c33388d7514b5db85decf8ca156d91efd4fe98d7cd8b42bc2c2fa81822a0ce9bd
7
- data.tar.gz: '0175953daedfe95efb9dc1777d38c2e6034e1822b0463fe50cf52dc946a17cd5a363bab862bc776399bd2e34c249b682298c2989f5ce7fa959cd667c4845d013'
6
+ metadata.gz: 7b1047f154815fde7e587fac75c1316ccf799a3ce73c8d5da97ae94305cc8368ea745f7472972a552da4a9df61acb54730d39a2080eb5e61e9fc46d234bbcfd0
7
+ data.tar.gz: 25d80f6b35509da21cbf0932a67187bd8f69ccac2f06c15e93dbc74a45c0ae4018145051f6d601df5b651aa33036d8cd4dcafefe800f5533110271a38500b4d7
data/.rubocop.yml CHANGED
@@ -10,32 +10,32 @@ Style/Documentation:
10
10
 
11
11
  Metrics/ClassLength:
12
12
  Exclude:
13
- - lib/json/repair/repairer.rb
13
+ - lib/json/repairer.rb
14
14
 
15
15
  Metrics/AbcSize:
16
16
  Exclude:
17
- - lib/json/repair/repairer.rb
17
+ - lib/json/repairer.rb
18
18
 
19
19
  Metrics/MethodLength:
20
20
  Exclude:
21
- - lib/json/repair/repairer.rb
21
+ - lib/json/repairer.rb
22
22
 
23
23
  Metrics/CyclomaticComplexity:
24
24
  Exclude:
25
- - lib/json/repair/repairer.rb
25
+ - lib/json/repairer.rb
26
26
 
27
27
  Metrics/PerceivedComplexity:
28
28
  Exclude:
29
- - lib/json/repair/repairer.rb
29
+ - lib/json/repairer.rb
30
30
 
31
31
  Metrics/BlockLength:
32
32
  Exclude:
33
- - lib/json/repair/repairer.rb
33
+ - lib/json/repairer.rb
34
34
  - spec/**/*
35
35
 
36
36
  Metrics/BlockNesting:
37
37
  Exclude:
38
- - lib/json/repair/repairer.rb
38
+ - lib/json/repairer.rb
39
39
 
40
40
  Metrics/ModuleLength:
41
41
  Exclude:
data/CHANGELOG.md CHANGED
@@ -2,4 +2,8 @@
2
2
 
3
3
  ### 2024-05-23 (0.1.0)
4
4
 
5
- * Initial setup
5
+ * Initial setup
6
+
7
+ ### 2024-06-01 (0.2.0)
8
+
9
+ * Moved the repair method to the JSON module
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # JSON::Repair
1
+ # JSON::Repair [![Gem Version](https://badge.fury.io/rb/json-repair.svg)](https://badge.fury.io/rb/json-repair) [![Build Status](https://github.com/sashazykov/json-repair-rb/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/sashazykov/json-repair-rb/actions)
2
2
 
3
- This is a Ruby gem designed to repair broken JSON strings. Inspired by the [jsonrepair js library](https://github.com/josdejong/jsonrepair/). It efficiently handles and corrects malformed JSON data, making it especially useful in scenarios where JSON output from LLMs might not strictly adhere to JSON standards. Whether it's missing quotes, misplaced commas, or unexpected characters, it ensures that the JSON data is valid and can be parsed correctly.
3
+ This is a Ruby gem designed to repair broken JSON strings. Inspired by and based on the [jsonrepair js library](https://github.com/josdejong/jsonrepair/). It efficiently handles and corrects malformed JSON data, making it especially useful in scenarios where JSON output from LLMs might not strictly adhere to JSON standards. Whether it's missing quotes, misplaced commas, or unexpected characters, it ensures that the JSON data is valid and can be parsed correctly.
4
4
 
5
5
  ## Installation
6
6
 
@@ -25,7 +25,7 @@ require 'json/repair'
25
25
 
26
26
  # Example of repairing a JSON string
27
27
  broken_json = '{name: Alice, "age": 25,}'
28
- repaired_json = JSON::Repair.repair(broken_json)
28
+ repaired_json = JSON.repair(broken_json)
29
29
  puts repaired_json # Outputs: {"name": "Alice", "age": 25}
30
30
  ```
31
31
 
@@ -48,3 +48,10 @@ The gem is available as open source under the terms of the [ISC License](https:/
48
48
  ## Code of Conduct
49
49
 
50
50
  Everyone interacting in the JSON::Repair project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/sashazykov/json-repair-rb/blob/main/CODE_OF_CONDUCT.md).
51
+
52
+ ## Similar libraries in other languages
53
+
54
+ - Typescript: https://github.com/josdejong/jsonrepair
55
+ - Go: https://github.com/RealAlexandreAI/json-repair
56
+ - JavaScript: https://github.com/RyanMarcus/dirty-json
57
+ - Python: https://github.com/mangiucugna/json_repair
@@ -2,6 +2,6 @@
2
2
 
3
3
  module JSON
4
4
  module Repair
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
data/lib/json/repair.rb CHANGED
@@ -1,14 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'repair/version'
4
- require_relative 'repair/repairer'
4
+ require_relative 'repairer'
5
5
 
6
6
  module JSON
7
- module Repair
8
- class JSONRepairError < StandardError; end
7
+ class JSONRepairError < StandardError; end
9
8
 
10
- def self.repair(json)
11
- Repairer.new(json).repair
12
- end
9
+ def self.repair(json)
10
+ Repairer.new(json).repair
13
11
  end
14
12
  end