Search code examples
sqljsonclickhouse

Parsing a single quotes json string clickhouse


I have json that needs to be parsed but the problem is that json's string values have a single quotes

{'name': None, 'medium': 'organic', 'source': 'google-play'}

Is there a way to parse this in clickhouse? Thank you


Solution

  • That's not a single quote JSON, it's only a print format of JSON Dict. But you can do this to convert it into a JSON:

    SELECT JSONExtractString(
      replaceAll(
        replaceAll(
          '{''name'': None, ''medium'': ''organic'', ''source'': ''google-play''}', '''', '"'
        ), 'None', 'null'
      ), 'medium'
    )