1

I have a json inside 'content' column in the following format:

  {  "identifier": [
        {
          "type": {
            "coding": [
              {
                "code": "MRN",
              }
            ]
          },
          "value": "181"
        },
        {
          "type": {
            "coding": [
              {
                "code": "PID",
              }
            ]
          },
          "value": "5d3669b0"
        },
        {
          "type": {
            "coding": [
              {
                "code": "IPN",
              }
            ]
          },
          "value": "41806"
        }
      ]}

I have to run an hive query to get the "value" of the code which is equal to "MRN". I have written the following query but its not giving the value as expected:

select get_json_object(content,'$.identifier.value')as Mrn from Doctor where get_json_object(content,'$.identifier.type.coding.code') like '%MRN%'

I dont want to give particular array position like:

select get_json_object(content,'$.identifier[0].value')as Mrn from Doctor where get_json_object(content,'$.identifier[0].type.coding.code') like '%MRN%'

As the json gets created randomly and the position is not fixed always.

0

1 Answer 1

2

Give [ * ] to avoid giving position.

select get_json_object(content,'$.identifier[*].value')as Mrn from Doctor where get_json_object(content,'$.identifier[*].type.coding.code') like '%MRN%'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.