0

I am using jsonpath_rw_ext for python currently

I am unable to come up with a path string that returns the fields I want without getting errors. I think I can get most of what I'm describing as individual fields however I can't put then together.

json object is an array of two objects:

[
{
    'id': 9707,
    'rev': 16,
    'fields': {
        'System.AssignedTo': {
            'id': 12345
            'descriptor': 'some-identifier',
            'displayName': 'Jeff Saremi',
        },
        'System.CommentCount': 7
},
{
    'id': 9708,
    'rev': 10,
    'fields': {
        'System.AssignedTo': {
            'id': 56789
            'descriptor': 'another-identifier',
            'displayName': 'Someone Else',
        },
        'System.CommentCount': 2
}
]

What I want in the results is: id (the topmost level one), fields.System.CommentCount and fields System.AssignedTo.displayName

I do not want deeper "id" levels

Here are what i have tried individually:

jp.match('$[*].id', workitems)

returns the toplevel IDs
jp.match('$..fields["System.CommentCount"]', workitems)

returns the commentcounts promptly
jp.match('$..fields..displayName', workitems)

returns the displayNames
Jeff Saremi
  • 2,674
  • 3
  • 33
  • 57

1 Answers1

0

Apparently this cannot be done not with the library I'm using.

I had to create 3 separate lists and zip then together to have one coherent resultset.

Jeff Saremi
  • 2,674
  • 3
  • 33
  • 57