@@ -10,7 +10,7 @@ use chrono::{DateTime, TimeZone, Utc};
10
10
use flate2:: read:: MultiGzDecoder ;
11
11
use futures:: FutureExt ;
12
12
use http:: StatusCode ;
13
- use lookup:: owned_value_path;
13
+ use lookup:: { event_path , owned_value_path} ;
14
14
use serde:: Serialize ;
15
15
use serde_json:: { de:: Read as JsonRead , Deserializer , Value as JsonValue } ;
16
16
use snafu:: Snafu ;
@@ -818,7 +818,7 @@ impl<'de, R: JsonRead<'de>> EventIterator<'de, R> {
818
818
}
819
819
820
820
for ( key, value) in object {
821
- log. insert ( key. as_str ( ) , value) ;
821
+ log. insert ( event_path ! ( key. as_str( ) ) , value) ;
822
822
}
823
823
}
824
824
_ => return Err ( ApiError :: InvalidDataFormat { event : self . events } . into ( ) ) ,
@@ -1571,6 +1571,28 @@ mod tests {
1571
1571
assert ! ( event. metadata( ) . splunk_hec_token( ) . is_none( ) ) ;
1572
1572
}
1573
1573
1574
+ #[ tokio:: test]
1575
+ async fn json_invalid_path_event ( ) {
1576
+ let ( sink, source) = start (
1577
+ JsonSerializerConfig :: default ( ) . into ( ) ,
1578
+ Compression :: gzip_default ( ) ,
1579
+ None ,
1580
+ )
1581
+ . await ;
1582
+
1583
+ let mut log = LogEvent :: default ( ) ;
1584
+ // Test with a field that would be considered an invalid path if it were to
1585
+ // be treated as a path and not a simple field name.
1586
+ log. insert ( event_path ! ( "(greeting | thing" ) , "hello" ) ;
1587
+ sink. run_events ( vec ! [ log. into( ) ] ) . await . unwrap ( ) ;
1588
+
1589
+ let event = collect_n ( source, 1 ) . await . remove ( 0 ) . into_log ( ) ;
1590
+ assert_eq ! (
1591
+ event. get( event_path!( "(greeting | thing" ) ) ,
1592
+ Some ( & Value :: from( "hello" ) )
1593
+ ) ;
1594
+ }
1595
+
1574
1596
#[ tokio:: test]
1575
1597
async fn line_to_message ( ) {
1576
1598
let ( sink, source) = start (
0 commit comments