我正在开发一个用户向服务器发送文本的应用程序。然后服务器更改文本,并以原始文本和修改后的文本进行响应。
如何表示在 JSON 中删除的文本。(删除线)
例如像这样:
我想过这样的事情:
包含所有文本的数组,拆分到包含笔划的位置和不包含笔划的位置:
data={
textBefore:'this is the first world. this is the second world',
textAfter:'this is first world. this is second world,
changes:[
{'nostroke':'this is th'},
{'stroe':'efirst world'},
{'nostroke':'in the third world'}
]
}
你有更好的主意吗?
或者像这样:
data={
textBefore:'this is the first world. this is the second world',
textAfter:'this is first world. this is second world,
changes:[
{from:2,to:22,text:'repace from char 2 to char 22 with this text'},
{from:2,to:4} // This will only delete 2 chars
{from:2,to:2,text:'This will only append this text without replae},
]