ShareJS中嵌套的JSON删除

时间:2012-07-04 01:08:21

标签: operational-transform

我目前正在试验ShareJSoperational transformation实现(特别是JSON API)。如果我删除了一个父JSON对象,并且另一个插入到子JSON中的操作,那么维基不清楚会发生什么。是重新创建父JSON,还是无操作?

E.g。

{"aa":
  {"bb":
    {"cc":"dd"}
  }
}
//Operation A and B comes in carrying the same version number
//Op A deletes "aa", Op B modifies "cc"
//What happens? (assuming A comes in slightly earlier and is processed first)

1 个答案:

答案 0 :(得分:1)

亲自检查一下:

op1 = [{p: ["aa"], od: {"bb": {"cc":"dd"}} }] // Deletes "aa"
op2 = [{p: ["aa", "bb", "cc"], od: "dd", oi: "ee"}] // Modifies "cc"
console.log(json.transform(op2, op1, 'left'))
>> []

这意味着,当op2在op1上转换时,它变为no-op - >不会重新创建任何对象。