Hi Alberto,

Yes you can take a look at my JSON_SQUASH

DROP FUNCTION JSON_SQUASH;
CREATE FUNCTION JSON_SQUASH(name string)
RETURNS string
BEGIN
  DECLARE res STRING;
  SET res = REPLACE(REPLACE(REPLACE(name, '[\"', ''), '\"]', ''), '"', '');
  IF (res = '[]') THEN
    SET res = REPLACE(res, '[]', '<no data>');
  END IF;
  RETURN res;
END;

SELECT
recv_date,
recv_time,
JSON_SQUASH(hostname) AS hostname
FROM 
(SELECT
a.recv_date AS recv_date,
a.recv_time AS recv_time,
json.filter(json_data, '$.http.host') AS hostname
FROM http_traffic_json a JOIN http_traffic_ua b 
ON (a.guid = b.guid)) AS origin WHERE recv_time BETWEEN CURTIME() - 300 AND CURTIME();

On Mon, May 2, 2016 at 11:29 PM, Alberto Ferrari <aferrari@starconnecting.com> wrote:
Hi Brian, thanks for your response.

Is there a way to filter what I need inside the first SELECT?
Something like this? ...

SELECT id, 
json.filter(json_data, '$.data.[?(time=2015-10-09*)]') AS time, /* I know this does not work, but it's in an example */
(...other fields...)
FROM tbljson;

 

2016-05-02 18:51 GMT-03:00 Brian Hood <brianh6854@googlemail.com>:
Hi Alberto,

I think this should help.

SELECT id, 
json.filter(json_data, '$.data.time') AS time,
json.filter(json_data, '$.data.others') AS others,
FROM tbljson;

Regards,

Brian Hood
 

_______________________________________________
users-list mailing list
users-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/users-list