Skip to content

Instantly share code, notes, and snippets.

View saiashirwad's full-sized avatar
🏠
Working from home

texoport saiashirwad

🏠
Working from home
View GitHub Profile
@gtors
gtors / underscore_to_camel_case
Created August 20, 2015 11:38
Postgresql function which converts json underscored keys to camel case keys.
CREATE FUNCTION key_underscore_to_camel_case(s text)
RETURNS json
IMMUTABLE
LANGUAGE sql
AS $$
SELECT to_json(substring(s, 1, 1) || substring(replace(initcap(replace(s, '_', ' ')), ' ', ''), 2));
$$;
-- TODO: add recursive processing
CREATE FUNCTION json_underscore_to_camel_case(data json)