Pointers 如何使用WDDX ColdFusion结构并维护指针或递归

Pointers 如何使用WDDX ColdFusion结构并维护指针或递归,pointers,struct,coldfusion,coldfusion-9,wddx,Pointers,Struct,Coldfusion,Coldfusion 9,Wddx,我正在使用WDDX在数据库中存储ColdFusion结构,我希望维护指针。下面是一个例子(对不起,简写符号可能充满了错误b/c我很少使用它): 现在,tshirt.front.color、tshirt.back.color和tshirt.color都是指向同一结构的指针。如果我将tshirt.color.selected更改为“蓝色”,则tshirt.back.color.selected和tshirt.front.color.selected也将为“蓝色” 但是,假设我是WDDX T恤,然后是

我正在使用WDDX在数据库中存储ColdFusion结构,我希望维护指针。下面是一个例子(对不起,简写符号可能充满了错误b/c我很少使用它):

现在,tshirt.front.color、tshirt.back.color和tshirt.color都是指向同一结构的指针。如果我将tshirt.color.selected更改为“蓝色”,则tshirt.back.color.selected和tshirt.front.color.selected也将为“蓝色”

但是,假设我是WDDX T恤,然后是unWDDX T恤。当我将tshirt.color.selected更改为“白色”时,它在tshirt.front.color.selected或tshirt.back.color.selected中不会更改

有人能提出另一种方法来序列化和取消序列化数据以保留指针吗?

到目前为止,我一直在使用几个链接进行研究:

使用,CF9中新增:

说明

转换ColdFusion数组、CFC、DateTime对象、Java对象、查询、, 或结构转换为可序列化的二进制对象,并可选择保存 文件中的对象

返回

对象的可序列化二进制表示形式


shirtdata=objectSave(tshirt);
tshirt2=对象负载(shirtdata);
tshirt2.color.selected=“蓝色”;
写输出(tshirt2.front.colors.selected);//“蓝色”=>保留参考

现场演示:

我很好奇它在向后兼容性方面的表现。听起来它是基于java模型的,它使用serialVersionUID。如果更改版本,并且序列化类的uid值更改,则无法在新版本中反序列化对象。希望CF能考虑到这一点。我做了一个从cf9到cf10以及从cf10到cf9的测试,它们都正常工作。@jessieloo-刚刚看到你的评论。您是否对CF9和10使用相同的jvm版本?@Leigh,它们不是相同的jvm版本。CF10是1.7.0_51_b13,CF9是1.6.0_17_b04
tshirt={color={selected="red",options=["red","blue","yellow","white"]}};
tshirt.front= {colors=tshirt.color,design="triangle",ink="green"};
tshirt.back= {color=tshirt.color,design="square",ink="black"};
<cfscript>
    shirtdata = objectSave(tshirt);
    tshirt2 = objectLoad(shirtdata);

    tshirt2.color.selected = "blue";
    writeOutput(tshirt2.front.colors.selected);  // "blue" => reference kept
</cfscript>