Quantcast
Channel: techscouting through the java news » Sönke Sothmann
Viewing all articles
Browse latest Browse all 72

JSON as core type in PostgreSQL 9.2

$
0
0

It looks like PostgreSQL 9.2 will get a JSON core type. Additionally, there will be functions to produce JSON data from database queries:

  • query_to_json()
  • array_to_json()
  • row_to_json()

Here is a simple example that uses the new query_to_json function:

SELECT query_to_json('select user_name as username, role_name as role from USER',false);

This query will produce JSON data:

[{"username":"testuser","role":"user"},{"username":"johndoe","role":"admin"}]

This could be very useful for web applications that use a lot of JSON data to communicate between the frontend and backend.


Einsortiert unter:Java Persistence Tagged: JSON, PostgreSQL

Viewing all articles
Browse latest Browse all 72