json and 9.3 function question

Поиск
Список
Период
Сортировка
От Rama
Тема json and 9.3 function question
Дата
Msg-id CALUit-eTka-4xNmC8gbxKTo3RfoCTQ3+fZbqxkv9xVuwUEj2tA@mail.gmail.com
обсуждение исходный текст
Список pgsql-novice
Hello,

i would like to make a query using the new 9.3 json functionality agains a json.

here a sample of data

{
  "Data": {
    "A": [
      {
        "B": { "b": "sample1" }
      },
      {
        "B": [
          { "b": "sample2" },
          { "b": "sample3" }
        ]
      }
    ]
  }
}

and what i want to achive is

select * from table where set_of_attribute_b not have 'sample3'::varchar



i have do some test the main issue is that B is an object (1st) and an array (2nd node)

with this query

select json_extract_path(json_array_elements(json_extract_path('{"Data": { "A": [ { "B": { "b": "1" } },{ "B": [{ "b": "1" },{ "b": "2" }]}]}}'::json,'Data','A')),'B')

i was able to extract two row, but the fist one is an object, the second is an array.

i am not able to use json_array_elements, i got an error for the 1st element begin an object rather than array, nor other approach.


any suggestion?









В списке pgsql-novice по дате отправления:

Предыдущее
От: Claudio Poli
Дата:
Сообщение: How to alias attributes in an ARRAY_AGG expression
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: How to alias attributes in an ARRAY_AGG expression