[ 
https://issues.apache.org/jira/browse/CALCITE-4989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17510360#comment-17510360
 ] 

Stamatis Zampetakis commented on CALCITE-4989:
----------------------------------------------

There is a 
[discussion|https://lists.apache.org/thread/qogmv8lz3gvfhjfm7p54shq333t035bj] 
in the dev list where someone mentioned that FORMAT JSON seems to solve the 
problem. However, in some quick 
[tests|https://github.com/zabetak/calcite/commit/988c13ce1ff551d6e4046a3c027ff298f79971f8]
 I did sometime ago using FORMAT JSON didn't seem to provide the desired output 
in all cases. Either my way of using FORMAT JSON is not the correct one either 
there is really a problem here.  

> Nested JSON_OBJECT creation does not produce proper json
> --------------------------------------------------------
>
>                 Key: CALCITE-4989
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4989
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.29.0
>            Reporter: Mans Singh
>            Priority: Critical
>              Labels: json_object, pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> I am trying to create a nested json object using JSON_OBJECT and am getting a 
> json with escaped quotes.  
>  
> I have the following query in sql line :
>  
> {code:java}
> select JSON_OBJECT(
>     KEY 'level1' 
>     VALUE(
>         JSON_OBJECT(
>             KEY 'level2' 
>             VALUE(
>                  JSON_OBJECT(
>                       KEY 'level3' 
>                       VALUE 'val3')
>                  )
>              )
>          ) 
>       ) 
> from (values ('{"a":{"b":2}}')) t(v);
>  
> {code}
> And it produces the result:
>  
> {noformat}
> -------------------------------------------------------------
>                            EXPR$0                            
> -------------------------------------------------------------
> {"level1":" {\"level2\":\"{\\\"level3\\\":\\\"val3\\\"}\"}"}
> -------------------------------------------------------------
> {noformat}
>  
> I was expecting the result as follows (without quote escapes):
>  
> {noformat}
> {"level1":{"level2":{"level3":"val3"}}}
>  
> {noformat}
> Also, see examples created by Stamatis
> - 
> [https://github.com/zabetak/calcite/commit/988c13ce1ff551d6e4046a3c027ff298f79971f8]



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to