英文:
how to remove the " \ " sign in the input in golang raw json
问题
以下是翻译好的内容:
这是一个输入示例:
[
{
"type":"非定制",
"so_no":"3250109150",
"material_code":"F100101180028",
"po_no":"JDC/00067/02/22/2/DL",
"pr_no":"",
"gr_no":"",
"gr_date":""
},
{
"type":"非定制",
"so_no":"3250109150",
"material_code":"F100101180030",
"po_no":"JDC/00067/02/22/2/DL",
"pr_no":"",
"gr_no":"",
"gr_date":""
}
]
请删除原始 JSON 输入中的 \ 符号。
请帮助能够修复它的人
英文:
and this is an example of its input
[
{
\"type\":\"Non Custom\",
\"so_no\":\"3250109150\",
\"material_code\":\"F100101180028\",
\"po_no\":\"JDC/00067/02/22/2/DL\",
\"pr_no\":\"\",
\"gr_no\":\"\",
\"gr_date\":\"\"
},
{
\"type\":\"Non Custom\",
\"so_no\":\"3250109150\",
\"material_code\":\"F100101180030\",
\"po_no\":\"JDC/00067/02/22/2/DL\",
\"pr_no\":\"\",
\"gr_no\":\"\",
\"gr_date\":\"\"
}
]
Remove the \ sign in raw json input
And please help who can fix it
答案1
得分: -1
为了解决这个问题,你可以将JSON转换为字符串,并替换每个反斜杠,如下所示:
json := `[
{
\"type\":\"Non Custom\",
\"so_no\":\"3250109150\",
\"material_code\":\"F100101180028\",
\"po_no\":\"JDC/00067/02/22/2/DL\",
\"pr_no\":\"\",
\"gr_no\":\"\",
\"gr_date\":\"\"
},
{
\"type\":\"Non Custom\",
\"so_no\":\"3250109150\",
\"material_code\":\"F100101180030\",
\"po_no\":\"JDC/00067/02/22/2/DL\",
\"pr_no\":\"\",
\"gr_no\":\"\",
\"gr_date\":\"\"
}
]`
fmt.Println(strings.ReplaceAll(json, "\\",""))
请注意,这是Go语言的代码示例,用于将JSON中的反斜杠替换为空字符串。
英文:
To solve this problem, you can pass the JSON into a string and replace every backslash like shown below:
json := `[
{
\"type\":\"Non Custom\",
\"so_no\":\"3250109150\",
\"material_code\":\"F100101180028\",
\"po_no\":\"JDC/00067/02/22/2/DL\",
\"pr_no\":\"\",
\"gr_no\":\"\",
\"gr_date\":\"\"
},
{
\"type\":\"Non Custom\",
\"so_no\":\"3250109150\",
\"material_code\":\"F100101180030\",
\"po_no\":\"JDC/00067/02/22/2/DL\",
\"pr_no\":\"\",
\"gr_no\":\"\",
\"gr_date\":\"\"
}
]`
fmt.Println(strings.ReplaceAll(json, "\\", ""))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论