第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

查找與JSON中的特定鍵值對(duì)匹配的給定格式的正則表達(dá)式

查找與JSON中的特定鍵值對(duì)匹配的給定格式的正則表達(dá)式

慕勒3428872 2021-05-07 14:23:42
'{“ id”:1,“ last”:“ Doe”,“ first”:“ John”,“ location”:{“ city”:“ Oakland”,“ state”:“ CA”,“ postalCode”:“ 94607“},” active“:true}','{” id“:2,” last“:” Doe“,” first“:” Jane“,” location“:{” city“:” San Francisco“, “ state”:“ WA”,“ postalCode”:“ 94105”},“ active”:false}','{“ id”:3,“ last”:“ Doe”,“ first”:“ Jane”,“ location“:{” city“:” San Francisco“,” state“:” CA“,” postalCode“:” 94105“},” active“:true}'我正在尋找包含'{“ id”:1}'的json包含?;蛘呶艺趯ふ野?#39;{“ location”:{“ state”:“ CA”},“ active”:true}'的json包含...同樣...因此,對(duì)于'{“ id”:1}',它應(yīng)該返回{{“ id”:1,“ last”:“ Doe”,“ first”:“ John”,“ location”:{“ city”:“ Oakland”,“ state”:“ CA”,“ postalCode”:“ 94607“},”活動(dòng)“:true}對(duì)于'{“ location”:{“ state”:“ CA”},“ active”:true}',它應(yīng)返回{“ id”:1,“ last”:“ Doe”,“ first”:“ John”,“ location”:{“ city”:“ Oakland”,“ state”:“ CA”,“ postalCode”:“ 94607 “},” active“:true} {” id“:3,” last“:” Doe“,” first“:” Jane“,” location“:{” city“:” San Francisco“,” state“: “ CA”,“ postalCode”:“ 94105”},“ active”:true}
查看完整描述

2 回答

?
哆啦的時(shí)光機(jī)

TA貢獻(xiàn)1779條經(jīng)驗(yàn) 獲得超6個(gè)贊

試試這個(gè): (.*"state":"CA".*"active":true.*)

演示:https : //regex101.com/r/hP6gS1/238

有用。

您可以根據(jù)需要更改標(biāo)簽名稱和值。它提取您所需的JSON內(nèi)容。


查看完整回答
反對(duì) 回復(fù) 2021-05-19
?
蝴蝶不菲

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超4個(gè)贊

Python版本


my_json = """[

    {

       "id": 1,

       "last": "Doe",

       "first": "John",

       "location": {

          "city": "Oakland",

          "state": "CA",

          "postalCode": "94607"

       },

       "active": true

    }, {

       "id": 2,

       "last": "Doe",

       "first": "Jane",

       "location": {

          "city": "San Francisco",

          "state": "WA",

          "postalCode": "94105"

       },

       "active": false

    }, {

       "id": 3,

       "last": "Doe",

       "first": "Jane",

       "location": {

          "city": "San Francisco",

          "state": "CA",

          "postalCode": "94105"

       },

       "active": true

    }

]"""


import json

my_list = json.loads(my_json)

result_list = list(filter(

        lambda d:

            d["id"] == 1 or \

            (d["location"]["state"] == "CA" and d["active"]),

        my_list

        ))


查看完整回答
反對(duì) 回復(fù) 2021-05-19
  • 2 回答
  • 0 關(guān)注
  • 355 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)