首页 > 解决方案 > GET with body (json format), what to do with apostrophe?

问题描述

I am new to REST. I have a client who tries call an api I have running. Problem is that they use some type of builder to create the body.

In my endpoint, I expect name field in the body like this:

{
"name": [
{ "tag": "1", "value": "O'Bryan" },
...

But client sends something like this:

{
'name': [
{'tag': '1 ', 'value': 'O'Bryan'}

It works except when name has apostrophe. I am wondering if this body will still valid. If not, what can they do to fix it without using double quote(")?

标签: rest

解决方案


This body will not be valid, you would need to escape the single quote like so \'


推荐阅读