jsonPath with special character

60 views
Skip to first unread message

nikolaos....@googlemail.com

unread,
Aug 31, 2016, 10:45:24 AM8/31/16
to Gatling User Group
Hi Guys,

the following jsonPath check doesn't find anything but if I check the expression with an online evaluator e.g. http://jsonpath.com/ then I'll get my object

'0' => "71"


### gatling-check
.check(jsonPath("$.rampup.jslobs.[?(@.id=='io.ox/core')].tree.folder.calendar").ofType[Int].saveAs(FID_CALENDAR))



### console:
---- Errors --------------------------------------------------------------------
> jsonPath($.rampup.jslobs.[?(@.id=='io.ox/core')].tree.folder.c      1 (100,0%)
alendar).find(0).exists, found nothing
================================================================================


### JSON:
{
   "session":"ed544b65b88b495d8f6d872cb7353b22",
   "user":"ntsapanidis@10",
   "user_id":7,
   "context_id":10,
   "locale":"en_US",
   "rampup":{
      "serverConfig":{},
      "jslobs":{
         "io.ox/core":{
            "id":"io.ox/core",
            "tree":{
               "refreshInterval":300000,
               "autoStart":"io.ox/mail/main",
               "autoOpenNotification":true,
               "autoLogout":0,
               "showDesktopNotifications":true,
               "settings":{
                  "downloadsDisabled":false
               },
               "properties":{
                  "maxBodySize":0,
                  "attachmentMaxUploadSize":10485760,
                  "infostoreMaxUploadSize":10485760,
                  "infostoreQuota":1073741824,
                  "infostoreUsage":1090384,
                  "attachmentQuota":104857600,
                  "attachmentQuotaPerFile":-1
               },
               "folder/hidden":{

               },
               "savepoints":[

               ],
               "viewer":{
                  "sidebarOpenState":true
               },
               "serverVersion":"7.8.2-Rev4",
               "timezone":"Europe/Berlin",
               "folder":{
                  "calendar":71,
                  "infostore":74,
                  "mailattachments":{

                  },
                  "eas":true,
                  "contacts":72,
                  "tasks":73
               },
               "language":"en_US",
               "search":{
                  "modules":[
                     "mail",
                     "contacts",
                     "calendar",
                     "tasks",
                     "drive"
                  ],
                  "mandatory":{
                     "folder":[
                        "mail"
                     ],
                     "account":null
                  }
               },
               "features":{
                  "validateMailAddresses":true
               },
               "password":{
                  "regexp":"[^a-z0-9]",
                  "maxLength":0,
                  "minLength":4,
                  "special":"$, _, or %",
                  "showStrength":false
               },
               "identifier":7,
               "user":{
                  "internalUserEdit":true
               },
               "pdf":{
                  "enableRangeRequests":true
               },
               "upsell":{
                  "enabled":{
                     "portal":false,
                     "infostore":false,
                     "tasks":false
                  }
               },
               "theme":"default"
            },
            "meta":{
               "pdf":{
                  "enableRangeRequests":{
                     "configurable":false
                  }
               },
               "upsell":{
                  "enabled":{
                     "portal":{
                        "configurable":false
                     },
                     "infostore":{
                        "configurable":false
                     },
                     "tasks":{
                        "configurable":false
                     }
                  }
               }
            }
         },
         "io.ox/core/updates":{
            "id":"io.ox/core/updates",
            "tree":{

            },
            "meta":{

            }
         },
         "io.ox/mail":{
            "id":"io.ox/mail",
            "tree":{
               "useFixedWidthFont":false,
               "autoSaveDraftsAfter":"disabled",
               "defaultSignature":false,
               "defaultReplyForwardSignature":false,
               "mobileSignatureType":"none",
               "threadSupport":true,
               "sort":"thread",
               "order":"desc",
               "unread":false,
               "simpleLineBreaks":true,
               "folderview":{
                  "visible":{
                     "large":true
                  },
                  "open":{
                     "large":[
                        "1",
                        "default0",
                        "virtual/standard"
                     ]
                  }
               },
               "viewOptions":{
                  "default0/INBOX":{
                     "sort":610,
                     "order":"desc",
                     "thread":false
                  },
                  "default0/Trash":{
                     "sort":610,
                     "order":"desc",
                     "thread":false
                  },
                  "default0/skata":{
                     "sort":610,
                     "order":"desc",
                     "thread":false
                  },
                  "default0/Spam":{
                     "sort":610,
                     "order":"desc",
                     "thread":false
                  },
                  "default0/fosse":{
                     "sort":610,
                     "order":"desc",
                     "thread":false
                  }
               },
               "layout":"vertical",
               "showContactPictures":false,
               "showExactDates":false,
               "alwaysShowSize":false,
               "showCheckboxes":false,
               "enforcesecureconnection":false,
               "contactCollectFolder":131,
               "removeDeletedPermanently":false,
               "appendMailTextOnReply":true,
               "messageFormat":"alternative",
               "defaultseparator":"/",
               "saveNoCopyInSentFolder":false,
               "compose":{
                  "shareAttachments":{
                     "threshold":0,
                     "enabled":true,
                     "forceAutoDelete":false,
                     "name":"Drive Mail",
                     "requiredExpiration":false
                  }
               },
               "namespace":"",
               "isColorQuoted":true,
               "contactCollectOnMailTransport":false,
               "defaultSendAddress":"ntsapanidis@zapox",
               "appendVcard":false,
               "addresses":[
                  "ntsapanidis@zapox"
               ],
               "defaultFolder":{
                  "drafts":"default0/Drafts-NEW",
                  "spam":"default0/Spam-NEW",
                  "inbox":"default0/INBOX",
                  "sent":"default0/Sent-NEW",
                  "trash":"default0/Trash-NEW"
               },
               "allowHtmlImages":true,
               "folder":{
                  "drafts":"default0/Drafts-NEW",
                  "spam":"default0/Spam-NEW",
                  "inbox":"default0/INBOX",
                  "sent":"default0/Sent-NEW",
                  "trash":"default0/Trash-NEW"
               },
               "displayEmoticons":true,
               "sendDispositionNotification":false,
               "showReplyTo":{
                  "configurable":false
               },
               "contactCollectOnMailAccess":false,
               "lineWrapAfter":80,
               "categories":{
                  "enabled":true,
                  "forced":false,
                  "initialized":"notyetstarted",
                  "list":[
                     {
                        "id":"general",
                        "name":"General",
                        "active":true,
                        "permissions":[
                           "train"
                        ]
                     },
                     {
                        "id":"promotion",
                        "name":"Promotions",
                        "active":true,
                        "permissions":[
                           "disable",
                           "train"
                        ]
                     },
                     {
                        "id":"social",
                        "name":"Social",
                        "active":true,
                        "permissions":[
                           "disable",
                           "train"
                        ]
                     },
                     {
                        "id":"purchases",
                        "name":"Purchases",
                        "active":true,
                        "permissions":[
                           "disable",
                           "train"
                        ]
                     },
                     {
                        "id":"custom1",
                        "name":"Friends",
                        "active":true,
                        "permissions":[
                           "disable",
                           "rename",
                           "train"
                        ]
                     },
                     {
                        "id":"custom2",
                        "name":"Work",
                        "active":true,
                        "permissions":[
                           "disable",
                           "rename",
                           "train"
                        ]
                     }
                  ]
               },
               "defaultaddress":"ntsapanidis@zapox",
               "forwardMessageAs":"Inline",
               "allowHtmlMessages":true,
               "unifiedInboxIdentifier":null,
               "archive":{
                  "days":90
               }
            },
            "meta":{

            }
         },
         "io.ox/contacts":{
            "id":"io.ox/contacts",
            "tree":{
               "showAdmin":false,
               "fullNameFormat":"auto",
               "startInGlobalAddressbook":true,
               "mapService":"google",
               "vgrid":{
                  "editable":false,
                  "previous":{
                     "6":"6.7",
                     "72":"72.17"
                  }
               },
               "folderview":{
                  "visible":{
                     "large":true
                  },
                  "open":{
                     "large":[
                        "virtual/flat/contacts/private",
                        "virtual/flat/contacts/public"
                     ]
                  }
               },
               "maxImageSize":4194304,
               "search":{
                  "minimumQueryLength":0,
                  "autocompleteFields":"first_name,last_name,display_name,email1,email2,email3"
               }
            },
            "meta":{

            }
         },
         "io.ox/calendar":{
            "id":"io.ox/calendar",
            "tree":{
               "interval":30,
               "startTime":8,
               "endTime":18,
               "defaultReminder":15,
               "viewView":"list",
               "showDeclinedAppointments":true,
               "markFulltimeAppointmentsAsFree":false,
               "deleteInvitationMailAfterAction":true,
               "vgrid":{
                  "editable":false,
                  "previous":{

                  }
               },
               "folderview":{
                  "visible":{
                     "large":true
                  },
                  "open":{
                     "large":[
                        "virtual/flat/calendar/private"
                     ]
                  }
               },
               "colorScheme":"custom",
               "showCheckboxes":false,
               "notifyNewModifiedDeleted":true,
               "notifyAcceptedDeclinedAsParticipant":true,
               "notifyAcceptedDeclinedAsCreator":true,
               "freeBusy":true
            },
            "meta":{

            }
         },
         "io.ox/caldav":{},
         "io.ox/files":{},
         "io.ox/tours":{},
         "io.ox/mail/emoji":{},
         "io.ox/tasks":{},
         "io.ox/office":{}
      },
      "oauth":{},
      "folder":{},
      "folderlist":{},
      "user":{},
      "accounts":[]
   }
}

Is there maybe a problem with the special character '/' in the jsonPath-Expression?

Thx
Niko


Stéphane LANDELLE

unread,
Aug 31, 2016, 11:25:55 AM8/31/16
to gat...@googlegroups.com
Mmm, IMO, your expression is not valid and the online evaluator you're using is crap.
Get a look at the pseudo spec, I don't think ".[?(" is valid.
Dots are separators, so child name is missing here (it would be * in your case).
I think we should crash on such expression, not return nothing.

Stéphane Landelle
GatlingCorp CEO


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stéphane LANDELLE

unread,
Aug 31, 2016, 12:12:09 PM8/31/16
to gat...@googlegroups.com

Stéphane Landelle
GatlingCorp CEO


nikolaos....@googlemail.com

unread,
Aug 31, 2016, 4:35:17 PM8/31/16
to Gatling User Group
Well I removed the dot and tried the expression, which looks valid to me, "$.rampup.jslobs[?(@.id=='io.ox/core')].tree.folder.calendar" again with different tools/testers and every tool/tester returns the correct identifier I'm looking for except gatlings jsonpath...

The tools I've used:
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.

Stéphane LANDELLE

unread,
Aug 31, 2016, 4:58:07 PM8/31/16
to gat...@googlegroups.com

Well I removed the dot

I said that foo.[?(@)] was invalid syntax.
I never said removing just removing the dot would give you he expression you need.
 
and tried the expression, which looks valid to me, "$.rampup.jslobs[?(@.id=='io.ox/core')].tree.folder.calendar" 

This one is syntactically valid, but still, it's not what you're looking for.
 
again with different tools/testers and every tool/tester returns the correct identifier I'm looking for except gatlings jsonpath...

Well, I've heard of cases where the majority was wrong.

jslobs is an object, so the [?(@.id=='io.ox/core')] filter should apply to it. But guess what? It doesn't have an id field, so there's just no way the filter could match something!

What you're looking for are "all the children of jslobs that have an id field whose value is io.ox/core".
Should be pretty easy to figure out :)

nikolaos....@googlemail.com

unread,
Aug 31, 2016, 6:53:09 PM8/31/16
to Gatling User Group
thx
Reply all
Reply to author
Forward
0 new messages