Encode shapes json in postgresql