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 +4 -4
- data/.rubocop.yml +7 -7
- data/CHANGELOG.md +5 -1
- data/README.md +10 -3
- data/lib/json/repair/version.rb +1 -1
- data/lib/json/repair.rb +4 -6
- data/lib/json/repairer.rb +645 -0
- data/sig/json/repair.rbs +2 -2
- metadata +3 -3
- data/lib/json/repair/repairer.rb +0 -647
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b50bffd203f06c7b7d2fa875802b66dd6fc944d01fe7c7f6c349233b2dc73d60
|
4
|
+
data.tar.gz: f018489c9572a61a72e9784af8f2b2fec335e215933ad0efea1265cff7d7be4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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/
|
13
|
+
- lib/json/repairer.rb
|
14
14
|
|
15
15
|
Metrics/AbcSize:
|
16
16
|
Exclude:
|
17
|
-
- lib/json/
|
17
|
+
- lib/json/repairer.rb
|
18
18
|
|
19
19
|
Metrics/MethodLength:
|
20
20
|
Exclude:
|
21
|
-
- lib/json/
|
21
|
+
- lib/json/repairer.rb
|
22
22
|
|
23
23
|
Metrics/CyclomaticComplexity:
|
24
24
|
Exclude:
|
25
|
-
- lib/json/
|
25
|
+
- lib/json/repairer.rb
|
26
26
|
|
27
27
|
Metrics/PerceivedComplexity:
|
28
28
|
Exclude:
|
29
|
-
- lib/json/
|
29
|
+
- lib/json/repairer.rb
|
30
30
|
|
31
31
|
Metrics/BlockLength:
|
32
32
|
Exclude:
|
33
|
-
- lib/json/
|
33
|
+
- lib/json/repairer.rb
|
34
34
|
- spec/**/*
|
35
35
|
|
36
36
|
Metrics/BlockNesting:
|
37
37
|
Exclude:
|
38
|
-
- lib/json/
|
38
|
+
- lib/json/repairer.rb
|
39
39
|
|
40
40
|
Metrics/ModuleLength:
|
41
41
|
Exclude:
|
data/CHANGELOG.md
CHANGED
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
|
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
|
data/lib/json/repair/version.rb
CHANGED
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 '
|
4
|
+
require_relative 'repairer'
|
5
5
|
|
6
6
|
module JSON
|
7
|
-
|
8
|
-
class JSONRepairError < StandardError; end
|
7
|
+
class JSONRepairError < StandardError; end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
end
|
9
|
+
def self.repair(json)
|
10
|
+
Repairer.new(json).repair
|
13
11
|
end
|
14
12
|
end
|