Обсуждение: inserting a text file via json

Поиск
Список
Период
Сортировка

inserting a text file via json

От
"john.tiger"
Дата:
we want to store markdown text files into our json fields - can this be
done ?  I guess we could have a separate json field and bytea field for
the markdown file but this might be difficult when it comes to our REST
response - anyone do something like this ?


Re: inserting a text file via json

От
Emanuel Calvo
Дата:

Did you mean something like...?:

postgres=# \! echo "{\"menu\": { \"id\": \"file\" }}" > /opt/pgdata/exampl.json
postgres=# select pg_read_file('/opt/pgdata/exampl.json');
        pg_read_file       
----------------------------
 {"menu": { "id": "file" }}+
 
(1 row)

postgres=# select pg_read_file('/opt/bdr/bdr1/exampl.json')::json;
        pg_read_file       
----------------------------
 {"menu": { "id": "file" }}+
 
(1 row)

postgres=# create table json_exam as select pg_read_file('/opt/bdr/bdr1/exampl.json')::json as jsonColumn;
SELECT 1
postgres=# \d json_exam 
   Table "public.json_exam"
   Column   | Type | Modifiers
------------+------+-----------
 jsoncolumn | json |

2014-09-05 20:51 GMT-03:00 john.tiger <john.tigernassau@gmail.com>:
we want to store markdown text files into our json fields - can this be done ?  I guess we could have a separate json field and bytea field for the markdown file but this might be difficult when it comes to our REST response - anyone do something like this ?


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



--
--
Emanuel Calvo http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services