Regular Expressions 101

Community Patterns

Extract a string key's values from a json

0

Regular Expression
Java 8

"
(?:\"(?:errorType)\"(?:[^:])*):(?:(?:[^\",])*)\"([^\"]*)
"
g

Description

Sample:

Finds errorType key values from a json. Values are returned in capturing group 1 of each match. Both UNKNOWN and UNAUTHENTICATED will be captured.

 {
  "data": null,
  "errors": [
    {
      "message": "Message",
      "extensions": {
        "errorType": "UNKNOWN",
        "error_code": "AUTHENTICATE_USER_FALSE"
      }
    },
    {
      "message": "Message",
      "extensions": {
        "errorType": "UNAUTHENTICATED",
        "error_code": "AUTHENTICATE_USER_FALSE"
      }
    }
  ]
}
Submitted by amansaryal - a year ago (Last modified a year ago)