json_mend 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/lib/json_mend/parser.rb +22 -28
- data/lib/json_mend/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cef80671ecf0296d0b0742bb94342c93a9cdf52e5def2ee4592a11f473ed6d6b
|
|
4
|
+
data.tar.gz: 831e6b821e39dff4adcf605e4f0beb53500ca846ac02a96e8c49e9822c7b1475
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a43f2089605d476414103b4333fe7d248856f27d0a8589041d7826905c611619a18fe45841dcf8e97bdfae90cfb6718d39323d0839c8fe97dbb584a54db4712f
|
|
7
|
+
data.tar.gz: 65c72349a8a6b721ef0f1a077bb69f82fe36fb499aa30da57f36fbc0dddfd4a7129082ffc32f940569af876fa8f43d4f626507652f5480b06fc7717b648cf418
|
data/.rubocop.yml
CHANGED
data/lib/json_mend/parser.rb
CHANGED
|
@@ -581,7 +581,6 @@ module JsonMend
|
|
|
581
581
|
)
|
|
582
582
|
char = peek_char
|
|
583
583
|
unmatched_delimiter = false
|
|
584
|
-
safe_string_until = -1 # Fast-forward pointer to safely bypass O(N^2) lookaheads
|
|
585
584
|
# --- Main Parsing Loop ---
|
|
586
585
|
while !@scanner.eos? && char != rstring_delimiter
|
|
587
586
|
# Fast-path for unquoted keys (e.g. { key: val })
|
|
@@ -600,33 +599,30 @@ module JsonMend
|
|
|
600
599
|
missing_quotes:
|
|
601
600
|
)
|
|
602
601
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
if current_context?(:object_value) && TERMINATORS_OBJECT_VALUE.include?(char) &&
|
|
606
|
-
(string_parts.empty? || string_parts.last != rstring_delimiter)
|
|
602
|
+
if current_context?(:object_value) && TERMINATORS_OBJECT_VALUE.include?(char) &&
|
|
603
|
+
(string_parts.empty? || string_parts.last != rstring_delimiter)
|
|
607
604
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
605
|
+
is_break = check_rstring_delimiter_missing(
|
|
606
|
+
string_parts:,
|
|
607
|
+
lstring_delimiter:,
|
|
608
|
+
rstring_delimiter:,
|
|
609
|
+
missing_quotes:
|
|
610
|
+
)
|
|
611
|
+
break if is_break
|
|
612
|
+
end
|
|
616
613
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
614
|
+
if char == ']' && context_contain?(:array) && string_parts.last != rstring_delimiter
|
|
615
|
+
i = skip_to_character(rstring_delimiter)
|
|
616
|
+
# No delimiter found
|
|
617
|
+
break unless peek_char(i)
|
|
618
|
+
end
|
|
622
619
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
end
|
|
620
|
+
if current_context?(:object_value) && char == '}'
|
|
621
|
+
# We found the end of an object while parsing a value
|
|
622
|
+
# Check if the object is really over, to avoid doubling the closing brace
|
|
623
|
+
i = skip_whitespaces_at(start_idx: 1)
|
|
624
|
+
next_c = peek_char(i)
|
|
625
|
+
break unless next_c
|
|
630
626
|
end
|
|
631
627
|
|
|
632
628
|
string_parts << char
|
|
@@ -644,7 +640,7 @@ module JsonMend
|
|
|
644
640
|
end
|
|
645
641
|
|
|
646
642
|
# If we are in object key context and we find a colon, it could be a missing right quote
|
|
647
|
-
if
|
|
643
|
+
if char == ':' && !missing_quotes && current_context?(:object_key)
|
|
648
644
|
is_break = handle_missing_quotes_termination(
|
|
649
645
|
lstring_delimiter:,
|
|
650
646
|
rstring_delimiter:
|
|
@@ -670,8 +666,6 @@ module JsonMend
|
|
|
670
666
|
string_parts << char.to_s
|
|
671
667
|
@scanner.getch
|
|
672
668
|
char = peek_char
|
|
673
|
-
|
|
674
|
-
safe_string_until = @scanner.pos + skip_to_character(rstring_delimiter)
|
|
675
669
|
end
|
|
676
670
|
end
|
|
677
671
|
end
|
data/lib/json_mend/version.rb
CHANGED