설문조사
PostgreSQL/PPAS 관련 듣고 싶은 교육은


총 게시물 94건, 최근 0 건
   

JSON (Javascript Object Notation)

글쓴이 : PostgresDBA 날짜 : 2013-04-07 (일) 20:29 조회 : 5848
9.2 부터는 JSON 을 내부적으로 지원합니다.
이런게 오픈소스의 매력이죠.

scott@[local]:5432:scottdb] 
SQL> select * from dept;
     10 | ACCOUNTING | NEW YORK
     20 | RESEARCH   | DALLAS
     30 | SALES      | CHICAGO
     40 | OPERATIONS | BOSTON

scott@[local]:5432:scottdb] 
SQL> select array_agg(d) from dept d;
 {"(10,ACCOUNTING,\"NEW YORK\")","(20,RESEARCH,DALLAS)","(30,SALES,CHICAGO)","(40,OPERATIONS,BOSTON)"}

scott@[local]:5432:scottdb] 
SQL> select array_to_json(array_agg(d)) from dept d;
 [{"deptno":10,"dname":"ACCOUNTING","loc":"NEW YORK"},{"deptno":20,"dname":"RESEARCH","loc":"DALLAS"},{"deptno":30,"dname":"SALES","loc":"CHICAGO"},{"deptno":40,"dname":"OPERATIONS","loc":"BOSTON"}]

scott@[local]:5432:scottdb] 
SQL> 

누워서 떡먹기네요. 근데, 누워서 먹으면 체하겠죠^^

   

postgresdba.com