PCRE RegEx,在“状态”之后出现不同于“确定”的状态]]

问题描述 投票:0回答:1

这些是我的带有JSON的健康端点:

{
  "JMS Server": {
    "message": "Successfully connected to JMS Server",
    "status": "OK"
  },
  "Database": {
    "message": "Database was successfully reached in 1ms",
    "status": "OK"
  },
  "Application": {
    "message": "IO Error Connection refused (Connection refused)",
    "status": "CRITICAL",
    "info": "URL = http://localhost/testing/healthcheck"
  }
}

{
  "JMS Server": {
    "message": "Successfully connected to JMS Server",
    "status": "OK"
  },
  "Database": {
    "message": "JDBC Connection failure",
    "status": "CRITICAL",
    "info": "No operations allowed after connection closed."
  },
  "Application": {
    "message": "Application is up",
    "status": "OK",
    "info": "Application name = Testing"
  }
}

在“状态”之后出现不同于“确定”的内容时,我需要PCRE RegEx。我不确定是否总是写“ CRITICAL”。

我在DuckDuckGo中搜索的不是运算符,但它在Regexr中从未起作用

这些是我的带有JSON的健康终结点:{“ JMS Server”:{“ message”:“已成功连接到JMS Server,” status“:” OK“},” Database“:{” message“:”成功...

regex shell pcre
1个回答
1
投票

@ Jan参数有效。绝对不要使用正则表达式解析JSON。但是,如果我们不必处理更复杂的语法(更多的内部对象,数组,不同的标量类型等)以及包含字符的更多域,那么我们可能会看到此要求为例外。

© www.soinside.com 2019 - 2024. All rights reserved.