0

I have a postgres database table named booking, which has a column summary of type text and the value is a json. I want to fetch all the rows in which the json key such as name has an apostrophe '

Such as (Magyl's Travels) in the sample below

"{
    'description' : 'Annual fees', 
    'name' : 'Business Name Magyl's Travels', 
    'amount' : 5000
},{
    'description' : 'Registration fees', 
    'name' : 'Business Name Magyl's Travels',
    'amount' : 15000
}"
Yannick Huber
  • 607
  • 2
  • 16
  • 35
user6781731
  • 13
  • 1
  • 5
  • Possible duplicate of [How to escape special characters in building a JSON string?](http://stackoverflow.com/questions/19176024/how-to-escape-special-characters-in-building-a-json-string) – Yannick Huber Feb 06 '17 at 07:50
  • 1
    `where strpos(summary, '''') > 0` –  Feb 06 '17 at 07:50
  • That's not valid JSON. Is this supposed to be an array with two objects? – Laurenz Albe Feb 06 '17 at 08:14
  • Yap,true,an arrayof objects,any idea how i can achieve my task – user6781731 Feb 06 '17 at 08:34
  • The json is not valid, so you won't be able to use any of the postgres json functions, but you might be able to do something with [postgres regex functions](https://www.postgresql.org/docs/9.3/static/functions-matching.html) – tocallaghan Feb 07 '17 at 00:53

0 Answers0