Skip to content

Commit 6e626d6

Browse files
committed
fixed a bug where the RFC6901 decoding wasn’t quite right.
added additional unit tests from the spec.
1 parent ff50633 commit 6e626d6

File tree

2 files changed

+49
-42
lines changed

2 files changed

+49
-42
lines changed

files/inputs/test1.json

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,49 @@
11
{
2-
"version": {
3-
"major": 2,
4-
"minor": 2,
5-
"patch": 1,
6-
"string": "2.2.1",
7-
"svn": 7191
8-
},
9-
"files": [
10-
"..\\path\\to\\files\\file1.txt",
11-
"..\\path\\to\\files\\file2.txt",
12-
"..\\path\\to\\files\\file3.txt",
13-
"test \u2FA4 \uABCD \uABCD\uABCDtest",
14-
" test \\u \" blah\\\" test test",
15-
"..\\path\\to\\files\\"
16-
],
17-
"empty_array": [
18-
],
19-
"empty_object": {
20-
},
21-
"empty_string": "",
22-
"data": [
23-
{
24-
"number": 1,
25-
"tf1": true,
26-
"tf2": false,
27-
"empty": null,
28-
"name": "Horatio",
29-
"array": [
30-
"1",
31-
"2",
32-
"3"
33-
]
34-
},
35-
{
36-
"number": 2,
37-
"integer": 33,
38-
"real": 0.2333000000000000E+003,
39-
"name": "Nelson"
40-
}
41-
]
2+
"version": {
3+
"major": 2,
4+
"minor": 2,
5+
"patch": 1,
6+
"string": "2.2.1",
7+
"svn": 7191
8+
},
9+
"files": [
10+
"..\\path\\to\\files\\file1.txt",
11+
"..\\path\\to\\files\\file2.txt",
12+
"..\\path\\to\\files\\file3.txt",
13+
"test \u2FA4 \uABCD \uABCD\uABCDtest",
14+
" test \\u \" blah\\\" test test",
15+
"..\\path\\to\\files\\"
16+
],
17+
"empty_array": [],
18+
"empty_object": {},
19+
"empty_string": "",
20+
"data": [{
21+
"number": 1,
22+
"tf1": true,
23+
"tf2": false,
24+
"empty": null,
25+
"name": "Horatio",
26+
"array": [
27+
"1",
28+
"2",
29+
"3"
30+
]
31+
}, {
32+
"number": 2,
33+
"integer": 33,
34+
"real": 0.2333000000000000E+003,
35+
"name": "Nelson"
36+
}],
37+
"rfc6901 tests": {
38+
"foo": ["bar", "baz"],
39+
"": 0,
40+
"a/b": 1,
41+
"c%d": 2,
42+
"e^f": 3,
43+
"g|h": 4,
44+
"i\\j": 5,
45+
"k\"l": 6,
46+
" ": 7,
47+
"m~n": 8
48+
}
4249
}

src/json_string_utilities.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,8 @@ pure subroutine replace_string(str,s1,s2)
796796
if (i>0) then
797797
if (i>1) tmp = tmp//str(1:i-1)
798798
tmp = tmp//s2 ! replace s1 with s2 in new string
799-
n = i+ilen1+1 ! start of remainder of str to keep
800-
if (n<ilen) then
799+
n = i+ilen1 ! start of remainder of str to keep
800+
if (n<=ilen) then
801801
str = str(n:ilen)
802802
else
803803
! done

0 commit comments

Comments
 (0)