【发布时间】:2021-02-27 01:45:56
【问题描述】:
IMGUR:https://imgur.com/a/uToKdKp
大家好, 假设我们有一个编辑器的屏幕,就像我们在 Stackoverflow 上的那样来起草一个问题。一旦我们点击提交,后端应该调用方法来生成一个 JSON。我的问题是:
- 如何存储 JSON 值?如果我有一个帖子并且我想更改文本的
color或font size,例如,这个字符串JSON (JavaScript Object Notation, pronounced /ˈdʒeɪsən/; also /ˈdʒeɪˌsɒn/) is an open standard file format, and data interchange format, that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and array data types (or any other serializable value)中的单词JSON而不会影响字符串的其余部分,那么正确的架构会像下面:
{
"title": title,
content: [
{
"type": "text",
"value": "<style="color:red">JSON</style> (JavaScript Object Notation, pronounced /ˈdʒeɪsən/; also /ˈdʒeɪˌsɒn/) is an open standard file format, and data interchange format, that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and array data types (or any other serializable value)."
},
{
"type": "image",
"value": "imageId"
}
]
}
-
如果我采用上述模式,一旦我从客户端取回 JSON,我预见到遍历整个字符串并解析出必要的样式时会出现问题。因此,我认为我的上述架构没有得到优化。处理这种情况的最佳方法是什么?
-
JSON 生成的流程:通常,当点击“发布”时,这个编辑器是否会向服务器发送一个 POST 请求,然后由服务器生成 JSON?如果是,那么该 POST 请求中包含什么?
【问题讨论】:
标签: javascript html css json architecture