You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it should be reproducible on any JSON api with relatively deep paths. If you try to parse $.node1.content it will work fine, whereas $.node2.subnode.content will not. The reason is the hash handling in sub parse_structure, currently arround line 447. The code used to split the $_->{id} in key and value look like this: if($_->{id} =~ /^(.+?)\.(.*)$/){ if (!defined($value->{$1}->{$2})) { $entry->{ $_->{id} } = ''; #...
The problem is that the first group of the regex is non-greedy. For the examples above, it will mean $value->{node1}->{content} #works and $value->{node2}->{subnode.content} #not defined, should be $value->{node2}->{subnode}->{content}.
In my post on thewatch, I suggested an additional sub to traverse arbitary depth JSON (or in Perl: hashes). I've tested it and it work for me. As I'm not this deep into Perl and Github as I should be, but feel free to adapt the code provided in my post to your coding standard and use it. Or find another clever solution
Expected result
Return the values that are actually contained in deep json
Actual result
The values of deep json are empty
The text was updated successfully, but these errors were encountered:
Thank you for this feedback and your contribution. I'll put this information in a dev ticket and we'll look at estimating and resolving it as soon as possible.
Quick description
HTTP collection is currently not capable traversing JSON path deeper then 2 nodes. The issue is discussed here: https://thewatch.centreon.com/data-collection-6/http-data-collection-path-depth-3639
How to reproduce
it should be reproducible on any JSON api with relatively deep paths. If you try to parse
$.node1.content
it will work fine, whereas$.node2.subnode.content
will not. The reason is the hash handling in subparse_structure
, currently arround line 447. The code used to split the $_->{id} in key and value look like this:if($_->{id} =~ /^(.+?)\.(.*)$/){ if (!defined($value->{$1}->{$2})) { $entry->{ $_->{id} } = ''; #...
The problem is that the first group of the regex is non-greedy. For the examples above, it will mean
$value->{node1}->{content} #works
and$value->{node2}->{subnode.content} #not defined, should be $value->{node2}->{subnode}->{content}
.In my post on thewatch, I suggested an additional sub to traverse arbitary depth JSON (or in Perl: hashes). I've tested it and it work for me. As I'm not this deep into Perl and Github as I should be, but feel free to adapt the code provided in my post to your coding standard and use it. Or find another clever solution
Expected result
Return the values that are actually contained in deep json
Actual result
The values of deep json are empty
The text was updated successfully, but these errors were encountered: