I want to delete the double quotes for changing it into Json object for drawing the picture.but after using many ways, I still can't resolve the problem.
You have an invalid JSON string
u cant use ' in json
they need to escaped double quotes \"
var x = [["{\"x\": 1}"]]
var json = JSON.parse(x[0][0])
Related
One of the keys in my dictionary is like this == > O "Models"
I want to delete this key. I know that this will be the last key always
I tried:
file1dictionary.Remove(O "Models")
file1dictionary.Remove("O "Models"")
Both have syntax errors
Double quotes in VB.Net strings are self-escaped, meaning you use two of them within the string literal to represent a quote contained in the string object, like this:
file1dictionary.Remove("O ""Models""")
I'm currently using iOS UIAutomation and identifying elements with a string generated from an external database that is populated with dynamic data. But iOS uiautomation throws a parser error when the string predicate contains a single quote.
Example:
UIATarget.localTarget().frontMostApp().mainWindow().collectionViews().firstWithPredicate(\"ANY visibleCells.name CONTAINS '" + title + "'")
Note that if title = "Todds Apartment" this locator works fine. But if the string contains a single quote it throws the parser error. So for example if title = "Todd's Apartment" this wouldn't work.
Is there a way for the predicate evaluation within single quotes to contain a single quote?
This is really a question about sanitizing input -- escaping strings for inclusion in a query string of some kind.
You should check out this question on escaping javascript strings for sql. You can probably solve your problem minimally by simply replacing \ with \\ and ' with \' in your input string.
Apple's documentation on predicates didn't seem to offer any information about what characters might need to be escaped.
I've written a plpgsql script which generates an array of json objects in a string but after I use to_json() method passing a variable with that string to it, it returns a result which is doublequoted and also every doublequote character is escaped. But I need that string as is.
initial content of jsonResult variable is:
[{"key":{04949429911,"Code":"400"},"value":"20000.00"},{"key":{"InsuranceNumber":"04949429911","Code":"403"},"value":"10000.00"},...]
but after to_json() it looks like this:
"[{\"key\":{04949429911,\"Code\":\"400\"},\"value\":\"20000.00\"},{\"key\":{\"InsuranceNumber\":\"04949429911\",\"Code\":\"403\"},\"value\":\"10000.00\"}...]"
This is the place where everything stored in jsonResult breakes:
UPDATE factor_value SET params = to_json(jsonResult) WHERE id = _id;
What am I doing wrong?
This answer points out that simply casting to json should suffice:
UPDATE factor_value SET params = jsonResult::json WHERE id = _id;
The weird escaping you see is probably due to postgresql not realizing you already have valid JSON and your varchar is just converted to a plain javascript/JSON string.
I needed to convert a bytea column to jsonb and I ended up with escaped characters when using to_json. I also used bytea_data_column::jsonb and postgres said cannot cast to jsonb. Here is how I worked around it:
bytea_data_column::text::jsonb
I want to have a string in the following format
"FAG001 FAG002 FAG003"
and want to split it into
"FAG001"
"FAG002"
"FAG003"
using a regular expression. Unfortunately my knowledge of regular expression synatax is limited to say teh least. I have tried things like
Dim result = Regex.Split(npcCodes, "([A-Z]3[0-9]3)").ToList
without luck
No need of regex here, you could use String.Split
Dim result As String() = npcCodes.Split(new Char[]{" "})
But if you really want to use regex :
Dim result = Regex.Split(npcCodes, " ").ToList()
As madgnome has pointed out you don't need regular expressions here if the string is always separated with spaces.
However for your information the error you made was that you need curly braces for numeric quantifiers:
[A-Z]{3}
And instead of Regex.Split you can uses Regex.Matches.
The regular expression to use in the Split method would be really simple:
Dim result = Regex.Split(npcCodes, " ").ToList
As the expression only matches a single character, you can just as well use the regular Split method in the String class:
Dim result = npcCodes.Split(" "C).ToList
I have updated many records already, but when it came to a word that contains a quote I get this error: "ERROR: Unclosed quote # 1357"
I know why it's giving me this error, I just don't how to solve it.
Here's a sample:
UPDATE invnum SET cAccountName = replace(cAccountName,'JOHN'S','BEN')
Thanks in advance.
Escape quotes inside strings:
UPDATE invnum SET cAccountName = replace(cAccountName,'JOHN\'S','BEN')
You want to be really careful with this - not dealing with this properly is the source of SQL injection attacks, and is a major source of security problems.
if you’re using a script to update your records use a builtin escaping function. for php that would be mysql_real_escape_string
Try this instead:
UPDATE invnum SET cAccountName = replace(cAccountName,"JOHN'S","BEN")
If you need to use both types of quotes within a string, then you'll need to escape the type of quotes you use to surround the string when they occur within it (otherwise the SQL interpreter will think the string ends before it actually does.
For instance:
Johns becomes "Johns"
John's becomes "John's" or 'John\'s'
"John" becomes '"John"' or "\"John\""
et cetera.