skip to Main Content
{
  "snippet-format": "empty-snippet",
  "total": 361,
  "start": 1,
  "page-length": 5,
  "selected": "include",
  "results": [
    {
      "index": 1,
      "uri": "/DEV/xyz-xyzRecord/OS1.json",
      "path": "fn:doc("/SIT1/xyz-xyzRecord/AB1.json")",
      "score": 0,
      "confidence": 0,
      "fitness": 0,
      "href": "/v1/documents?uri=%2FDEV%2FIxyz-xyzRecord%2FOS1.json&database=data-hub-DEV",
      "mimetype": "application/json",
      "format": "json",
      "matches": null,
      "extracted": {
        "kind": "array",
        "content": [
          {
            "xyz": "AB1"
          }
        ]
      }
    }
  ]
}

Expected output is

[
  {
    "xyz": "AB1"
  }
]

2

Answers


  1. You can use the following shift transformation spec

    [
      {
        "operation": "shift",
        "spec": {
          "@results[0].extracted.content": ""
        }
      }
    ]
    

    Another option might be

    [
      {
        "operation": "shift",
        "spec": {
          "results": {
            "*": {
              "extracted": {
                "content": {
                  "*": "[]"
                }
              }
            }
          }
        }
      }
    ]
    
    Login or Signup to reply.
  2. @Barbaros But what if multiple objects

    {
      "snippet-format": "empty-snippet",
      "total": 361,
      "start": 1,
      "page-length": 5,
      "selected": "include",
      "results": [
        {
          "index": 1,
          "uri": "/DEV/xyz-xyzRecord/OS1.json",
          "path": "fn:doc("/SIT1/xyz-xyzRecord/AB1.json")",
          "score": 0,
          "confidence": 0,
          "fitness": 0,
          "href": "/v1/documents?uri=%2FDEV%2FIxyz-xyzRecord%2FOS1.json&database=data-hub-DEV",
          "mimetype": "application/json",
          "format": "json",
          "matches": null,
          "extracted": {
            "kind": "array",
            "content": [
              {
                "xyz": "AB1"
              }
            ]
          }
        },
        {
          "index": 2,
          "uri": "/DEV/xyz-xyzRecord/anc.json",
          "path": "fn:doc("/SIT1/xyz-xyzRecord/anc.json")",
          "score": 0,
          "confidence": 0,
          "fitness": 0,
          "href": "/v1/documents?uri=%2FDEV%2FIxyz-xyzRecord%2FOS1.json&database=data-hub-DEV",
          "mimetype": "application/json",
          "format": "json",
          "matches": null,
          "extracted": {
            "kind": "array",
            "content": [
              {
                "xyz": "AB133"
              }
            ]
          }
        }
      ]
    }
    

    Spec tried

    [
      {
        "operation": "shift",
        "spec": {
          "results": {
            "*": {
              "@extracted.content": ""
            }
          }
        }
      }
    ]
    
    

    Below output

    [
      {
        "xyz": "AB1"
      },
      [
        {
          "xyz": "AB113"
        }
      ]
    ]
    

    But Expected

    [
      {
        "xyz": "AB1"
      },
      {
        "xyz": "AB133"
      }
    ]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search