Skip to content

Instantly share code, notes, and snippets.

@luzluna
luzluna / gist:1576fca2ae7f21333195
Created May 7, 2015 06:20
Perl JSON perserve order
use Tie::IxHash;
use JSON;
use Data::Dump qw/dump/;
my $json = '{"test":"test","test2":"test2","test4":"test4","test3":"test3"}';
my $obj_parser_sub = \&JSON::PP::object;
*JSON::PP::object = sub {
tie my %obj, 'Tie::IxHash';
@luzluna
luzluna / hstore_to_json.patch
Created April 4, 2013 02:05
Postgres 9.2.3 hstore patch for hstore_to_json(), hstore_to_json_loose() function. backport from 9.3 development branch.
diff -rupN hstore/hstore--1.1.sql hstore_hstore_to_json/hstore--1.1.sql
--- hstore/hstore--1.1.sql 2013-02-05 06:28:13.000000000 +0900
+++ hstore_hstore_to_json/hstore--1.1.sql 2013-04-04 10:53:53.000000000 +0900
@@ -234,6 +234,19 @@ LANGUAGE C IMMUTABLE STRICT;
CREATE CAST (text[] AS hstore)
WITH FUNCTION hstore(text[]);
+CREATE FUNCTION hstore_to_json(hstore)
+RETURNS json
+AS 'MODULE_PATHNAME', 'hstore_to_json'