如果我使用gettext()方法,有没有办法只获取json数据

kqqjbcuj  于 2021-07-06  发布在  Java
关注(0)|答案(1)|浏览(339)

在其中一个场景中,我必须验证json内容,但是当我使用gettext()方法检索内容时,它会给我所有元素。我只需要获取json内容,这样我就可以验证了。我只想json对象应该取得相同的,我可以保存在json文件进一步验证。
e、 g.这就是div的样子:

<div id="postMessageDiv">
        <div class="msg">
            <span class="MethodNameMsg">Post Message Function/ Method Name:</span>
            <span class="MethodName">loadModule</span>
        </div>
        <br>Data: 
        <br>
        {
      "fnToCall": "loadModule",
      "finappId": "10003592",
      "containerFinapp": true
    }
    <br>
    Page Height Sent By Framework:::: 656
    <br>
    Page Height Sent By Framework:::: 815
    <br>
    Page Height Sent By Framework:::: 996
    <div class="msg">
                                <span class="MethodNameMsg">Post Message Function/ Method Name:</span>
                                <span class="MethodName">loadModule</span>
                            </div>
                            <br>Data: 
                            <br>
                            {
      "fnToCall": "loadModule",
      "finappId": "10003593",
      "containerFinapp": true
    }
    <br>Page Height Sent By Framework:::: 684
    <br>Page Height Sent By Framework:::: 656
    <div class="msg">
    <span class="MethodNameMsg">Post Message Function/ Method Name:</span>
    <span class="MethodName">accountStatus</span>
                                            </div>
                                            <br>Data: 
                                            <br>
                                            {
      "fnToCall": "accountStatus",
      "action": "exit",
      "sites": [
        {
          "providerAccountId": 10102587,
          "bankName": "Dag Site (United States)",
          "status": "IN_PROGRESS",
          "providerId": 16441,
          "requestId": "NGj/NgqlHsZ6W2k8NcWSJY3MSkY=",
          "statusCode": "ACCT_SUMMARY_RECEIVED"
        }
      ]
    }</div>

输出响应:如果我使用的是gettext(),则得到以下响应:

Post Message Function/ Method Name: loadModule

        Data: 
        {
          "fnToCall": "loadModule",
          "finappId": "10003592",
          "containerFinapp": true
        }
        Page Height Sent By Framework:::: 656
        Page Height Sent By Framework:::: 830
        Page Height Sent By Framework:::: 849
        Page Height Sent By Framework:::: 831
        Post Message Function/ Method Name: loadModule

        Data: 
        {
          "fnToCall": "loadModule",
          "finappId": "10003593",
          "containerFinapp": true
        }
        Page Height Sent By Framework:::: 684
        Post Message Function/ Method Name: accountStatus

        Data: 
        {
          "fnToCall": "accountStatus",
          "action": "exit",
          "sites": [
            {
              "providerAccountId": 10102575,
              "bankName": "Dag Site",
              "status": "IN_PROGRESS",
              "providerId": 16441,
              "requestId": "P7b1oRBi4geKPVhmS7cPRnqcVPU=",
              "statusCode": "ACCT_SUMMARY_RECEIVED"
            }
          ]
        }

对于gettext,只有main div可以工作,我只需要json对象进行验证。如果我可以得到json对象,我就可以使用json库轻松地验证内容

y1aodyip

y1aodyip1#

gettext()返回节点之间的innertext,没有仅获取json的选项。因此,必须用所用的编程语言解析返回的数据。

相关问题