agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: msn <pioneer.suri@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Getting the queried result in the form of json structure
Date: Tue, 26 Apr 2016 04:32:00 -0700 (MST)
Message-ID: <1461670320290-5900554.post@n5.nabble.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

I am using postgresql for my webapplication. I am new to this
Postgresql-json. I Just want to get the select query result in the form of
json structure.
Here are my details:

    Create table
    ============
    - create table sample(id, serial, info jsonb);
    Insert query
    ============
    - insert into sample("info") values('{"person": {"phone":
9804484234,"name":{"firstname":"Alice", "lastname":"bob"}, "empId": "E067",
"age":25}');
    
    select query:
    =============
    select "info"->'person'->>'lastname' from sample;
    
    result: bob
    
    but I want to get the above result along with the json nodes like below:
    
    result: {"person":
              {"name":
                {"lastname":"bob"}
              }
            }

could any tell me how to get my expected result structure from database.




--
View this message in context: http://postgresql.nabble.com/Getting-the-queried-result-in-the-form-of-json-structure-tp5900554.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (7+ messages)  latest in thread

Message-ID: <1461670320290-5900554.post@n5.nabble.com>
Permalink:  ../1461670320290-5900554.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1461670320290-5900554.post@n5.nabble.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pioneer.suri@gmail.com
  Subject: Re: Getting the queried result in the form of json structure
  In-Reply-To: <1461670320290-5900554.post@n5.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox