escaping - Passing apostrophe as part of JSON string -
i have problem json service not being called, due bad format probably.
still, dont understand wrong it. read , found out apostrophes should not escaped. when escape them, doesnt work.
"{ "fields": [ { "text": "paymentreminders", "value": "'yes'" } ] }"
and yes, need 'yes' under apostrophes.
i expecting string on server side, deserialize. works without apostrophes.
thanks!
edit1:
this structure accepts in on server:
public class templatefield public property value() string = "val" public property text() string = "tex" end class public class fieldslist public property fields() templatefield() end class
and gets deserialzed this:
dim jsserializer new javascriptserializer dim fieldsarray eventinfodetails.fieldslist fieldsarray = jsserializer.deserialize(of eventinfodetails.fieldslist)(fields)
and works, unless contains apostrophes. cannot stick apostrophe inside string.
json not not require escape apostrophes, in fact not allow doing (contrary javascript). your
"value": "'yes'"
is valid json. is, unless inserting json string literal inside javascript code, in case javascript 1 requiring escape '
\'
(you'd need 2 escapes, json 1 , javascript 1 on top of it).
anyway, there's strange code:
"{ "fields": [ { "text": "paymentreminders", "value": "'yes'" } ] }"
why entire json structure surrounded quotes ("
)? string literal of kind inside other programming language? in such case, might need follow language's escaping rules quote ("
) symbols. both java , vb, example, use \"
there...
Comments
Post a Comment