gpt4 book ai didi

web-services - REST/JSON : Should I include a newline after the JSON string?

转载 作者:行者123 更新时间:2023-12-04 05:16:00 25 4
gpt4 key购买 nike

如果我从 RESTful Web 查询返回 ["foo"],以下哪个更合适?迂腐的 REST 解析会在换行符上消失吗?

["foo"]\n     (with newline, Content-Length=8)
["foo"] (no newline, Content-Length=7)

为了便于回归测试,我喜欢带有换行符的表单,但我想确保我不会破坏任何可能对 REST 格式有更严格 View 的应用程序框架。

最佳答案

引自 RFC 4627 , 粗体 强调的相关部分。

A JSON text is a sequence of tokens. The set of tokens includes six structural characters, strings, numbers, and three literal names.

A JSON text is a serialized object or array.

 JSON-text = object / array

These are the six structural characters:

 begin-array     = ws %x5B ws  ; [ left square bracket

begin-object = ws %x7B ws ; { left curly bracket

end-array = ws %x5D ws ; ] right square bracket

end-object = ws %x7D ws ; } right curly bracket

name-separator = ws %x3A ws ; : colon

value-separator = ws %x2C ws ; , comma

Insignificant whitespace is allowed before or after any of the six structural characters.

关于web-services - REST/JSON : Should I include a newline after the JSON string?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2671775/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com