File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ def initialize(path, opts = {})
30
30
until scanner . eos?
31
31
if ( token = scanner . scan ( /\$ \B |@\B |\* |\. \. / ) )
32
32
@path << token
33
- elsif ( token = scanner . scan ( /[$@a-zA-Z0-9 :{}_-]+/ ) )
33
+ elsif ( token = scanner . scan ( /[$@\p {Alnum} :{}_-]+/ ) )
34
34
@path << "['#{ token } ']"
35
35
elsif ( token = scanner . scan ( /'(.*?)'/ ) )
36
36
@path << "[#{ token } ]"
@@ -85,7 +85,7 @@ def on(obj_or_str, opts = {})
85
85
end
86
86
a
87
87
end
88
-
88
+
89
89
def self . fetch_all_path ( obj )
90
90
all_paths = [ '$' ]
91
91
find_path ( obj , '$' , all_paths , obj . class == Array )
Original file line number Diff line number Diff line change @@ -245,7 +245,7 @@ def test_use_first
245
245
end
246
246
247
247
def test_counting
248
- assert_equal 57 , JsonPath . new ( '$..*' ) . on ( @object ) . to_a . size
248
+ assert_equal 58 , JsonPath . new ( '$..*' ) . on ( @object ) . to_a . size
249
249
end
250
250
251
251
def test_space_in_path
@@ -475,6 +475,11 @@ def test_support_underscore_in_member_names
475
475
JsonPath . new ( '$.store._links' ) . on ( @object )
476
476
end
477
477
478
+ def test_support_for_umlauts_in_member_names
479
+ assert_equal [ @object [ 'store' ] [ 'Übermorgen' ] ] ,
480
+ JsonPath . new ( '$.store.Übermorgen' ) . on ( @object )
481
+ end
482
+
478
483
def test_dig_return_string
479
484
assert_equal [ 'asdf' ] , JsonPath . new ( "$.store.book..tags[?(@ == 'asdf')]" ) . on ( @object )
480
485
assert_equal [ ] , JsonPath . new ( "$.store.book..tags[?(@ == 'not_asdf')]" ) . on ( @object )
@@ -1246,10 +1251,11 @@ def example_object
1246
1251
} ,
1247
1252
'@id' => 'http://example.org/store/42' ,
1248
1253
'$meta-data' => 'whatevs' ,
1254
+ 'Übermorgen' => 'The day after tomorrow' ,
1249
1255
'_links' => { 'self' => { } }
1250
1256
} }
1251
1257
end
1252
-
1258
+
1253
1259
def test_fetch_all_path
1254
1260
data = {
1255
1261
"foo" => nil ,
You can’t perform that action at this time.
0 commit comments