基本的な質問に対して謝罪しますが、私は正規表現に慣れていないので、私が直面している問題の解決策を見つけるのに本当に苦労しています。RegExを使用して特定のフィールドを特定する
私はそれを呼び出すたびに変更できるjsonレスポンスから特定のフィールドを動的に取り出そうとしています。
応答は次のとおりです。
[{"colorPartNumber":"10045112022164298","skuPartNumber":"0400218072057","productColor":{"identifier":"Dark blue","label":"Dark blue","hex":"#0000A0"},"productSize":{"identifier":"0","label":"0","name":"Designer","scaleLabel":"apparel-wmn","schema":{"name":"UK","labels":["8"]}},"soldOut":true,"onlyOneLeft":false,"limitedAvailability":false,"preorder":false,"comingSoon":false,"visible":true,"displayable":true,"buyable":false,"availableInPhysicalStore":false,"expectedShippingDate":null},{"colorPartNumber":"10045112022164298","skuPartNumber":"0400094632819","productColor":{"identifier":"Dark blue","label":"Dark blue","hex":"#0000A0"},"productSize":{"identifier":"1","label":"1","name":"Designer","scaleLabel":"apparel-wmn","schema":{"name":"UK","labels":["10"]}},"soldOut":true,"onlyOneLeft":false,"limitedAvailability":false,"preorder":false,"comingSoon":false,"visible":true,"displayable":true,"buyable":false,"availableInPhysicalStore":false,"expectedShippingDate":null},{"colorPartNumber":"10045112022164298","skuPartNumber":"0400218072040","productColor":{"identifier":"Dark blue","label":"Dark blue","hex":"#0000A0"},"productSize":{"identifier":"2","label":"2","name":"Designer","scaleLabel":"apparel-wmn","schema":{"name":"UK","labels":["12"]}},"soldOut":true,"onlyOneLeft":false,"limitedAvailability":false,"preorder":false,"comingSoon":false,"visible":true,"displayable":true,"buyable":false,"availableInPhysicalStore":false,"expectedShippingDate":null},{"colorPartNumber":"10045112022164298","skuPartNumber":"0400468014814","productColor":{"identifier":"Dark blue","label":"Dark blue","hex":"#0000A0"},"productSize":{"identifier":"3","label":"3","name":"Designer","scaleLabel":"apparel-wmn","schema":{"name":"UK","labels":["14"]}},"soldOut":false,"onlyOneLeft":true,"limitedAvailability":false,"preorder":false,"comingSoon":false,"visible":true,"displayable":true,"buyable":true,"availableInPhysicalStore":false,"expectedShippingDate":null}]
私はskuPartNumberを引き出すしようとしていますが、「buyable」値がtrueに設定されている場合のみ。
私はこの1つのだけ値:(私は引き出すしたい値だけ上記の例ではそう
0400468014814
あるのように見えることはできませんしてみてください。
このJSONすべてのものが動的であるができたので、戻ってくる100個の値であってもよいが、原理は同じである。失敗したの
一例は間違っている、私だけの非常に最初の値を与えるskuPartNumber(.*?)"buyable":true
、(0400218072057
)である。
基本的な質問をもう一度お詫び申し上げます。
なぜこのタスクにregexを使用し、JSONをライブラリで解析するだけではないのですか?強烈に思える。 – Jokab
良い質問です。 LoadRunnerというツールを使用してアプリケーションのパフォーマンスをテストしています。その一環として、JSONレスポンスから動的に値を取得し、それを後続のリクエストにプッシュする必要があります。 LoadRunnerはJSONをあまりサポートしていませんが、RegExをサポートしているので、これは良い選択のようです。 – Shaqattack
[LoadRunnerはJSON解析をサポートしているようです。](https://community.saas.hpe.com/t5/LoadRunner-and-Performance/Get-a-new-way-to-manipulate-JSON-with-load-testing -in-LoadRunner/ba-p/234409#.WUDpx2j1CUk) – jxh