-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add function isValidJSON #7293
Add function isValidJSON #7293
Changes from all commits
1174fc3
9a9a234
62c7c50
f1630b4
797f76a
a0ca932
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,10 @@ | |
1 | ||
1 | ||
0 | ||
--isValidJSON-- | ||
1 | ||
0 | ||
0 | ||
--JSONKey-- | ||
a | ||
b | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,11 @@ SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'a'); | |
SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'b'); | ||
SELECT JSONHas('{"a": "hello", "b": [-100, 200.0, 300]}', 'c'); | ||
|
||
SELECT '--isValidJSON--'; | ||
SELECT isValidJSON('{"a": "hello", "b": [-100, 200.0, 300]}'); | ||
SELECT isValidJSON('not a json'); | ||
SELECT isValidJSON('"HX-='); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then you'll be able to pass additional argument to isValidJSON. I don't know if it's appropriate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems it's all about the name: |
||
|
||
SELECT '--JSONKey--'; | ||
SELECT JSONKey('{"a": "hello", "b": [-100, 200.0, 300]}', 1); | ||
SELECT JSONKey('{"a": "hello", "b": [-100, 200.0, 300]}', 2); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the name
JSONIsValid()
would be more consistent with other names.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. BTW, isValidJSON is consistent with isValidUTF8.