diff --git a/postgrest.cabal b/postgrest.cabal
--- a/postgrest.cabal
+++ b/postgrest.cabal
@@ -2,7 +2,7 @@
 description:           Reads the schema of a PostgreSQL database and creates RESTful routes
                        for the tables and views, supporting all HTTP verbs that security
                        permits.
-version:               0.2.12.0
+version:               0.2.12.1
 synopsis:              REST API for any Postgres database
 license:               MIT
 license-file:          LICENSE
diff --git a/src/PostgREST/Parsers.hs b/src/PostgREST/Parsers.hs
--- a/src/PostgREST/Parsers.hs
+++ b/src/PostgREST/Parsers.hs
@@ -18,6 +18,7 @@
 import           Network.Wai                   (Request, pathInfo, queryString)
 import           PostgREST.Types
 import           Text.ParserCombinators.Parsec hiding (many, (<|>))
+
 parseGetRequest :: Request -> Either ParseError ApiRequest
 parseGetRequest httpRequest =
   foldr addFilter <$> (addOrder <$> apiRequest <*> ord) <*> flts
@@ -77,7 +78,7 @@
 pTreePath :: Parser (Path,Field)
 pTreePath = do
   p <- pFieldName `sepBy1` pDelimiter
-  jp <- optionMaybe ( string "->" >>  pJsonPath)
+  jp <- optionMaybe pJsonPath
   let pp = map cs p
       jpp = map cs <$> jp
   return (init pp, (last pp, jpp))
@@ -98,14 +99,14 @@
 pFieldName =  cs <$> (many1 (letter <|> digit <|> oneOf "_")
       <?> "field name (* or [a..z0..9_])")
 
-pJsonPathDelimiter :: Parser Text
-pJsonPathDelimiter = cs <$> (try (string "->>") <|> string "->")
+pJsonPathStep :: Parser Text
+pJsonPathStep = cs <$> try (string "->" *> pFieldName)
 
 pJsonPath :: Parser [Text]
-pJsonPath = pFieldName `sepBy1` pJsonPathDelimiter
+pJsonPath = (++) <$> many pJsonPathStep <*> ( (:[]) <$> (string "->>" *> pFieldName) )
 
 pField :: Parser Field
-pField = lexeme $ (,) <$> pFieldName <*> optionMaybe ( pJsonPathDelimiter *>  pJsonPath)
+pField = lexeme $ (,) <$> pFieldName <*> optionMaybe pJsonPath
 
 pSelect :: Parser SelectItem
 pSelect = lexeme $
diff --git a/src/PostgREST/PgQuery.hs b/src/PostgREST/PgQuery.hs
--- a/src/PostgREST/PgQuery.hs
+++ b/src/PostgREST/PgQuery.hs
@@ -116,7 +116,7 @@
 asJson :: StatementT
 asJson s = s {
   B.stmtTemplate =
-    "array_to_json(array_agg(row_to_json(t)))::character varying from ("
+    "array_to_json(coalesce(array_agg(row_to_json(t)), '{}'))::character varying from ("
     <> B.stmtTemplate s <> ") t" }
 
 withCount :: StatementT
diff --git a/test/SpecHelper.hs b/test/SpecHelper.hs
--- a/test/SpecHelper.hs
+++ b/test/SpecHelper.hs
@@ -184,4 +184,6 @@
       [H.stmt|
         insert into "1".json (data) values (?)
       |]
-      (J.object [("foo", J.object [("bar", J.String "baz")])])
+      (J.object [("id", J.Number 1)
+                ,("foo", J.object [("bar", J.String "baz")])
+                ])
