2

如果我从 Zend_Amf 向 Flex 发送远程数据,如果对象上的两个数组属性具有相同的数据值,则它们在远程端使用相同的内存存储进行反序列化。

示例:AS3 对象:

片段:

[RemoteClass(alias="TestVO")]
public class TestVO
{
  public var test1:Array;
  public var test2:Array;
}

当它从 Zend_Amf 服务器接收远程数据时,如果数组数据相同,它会为两个数组分配相同的存储空间。

例如:从我发送的远程(ZendAMF)对象:

$this->test1 = array("foo", "bar");
$this->test2 = array("foo", "bar");

当我在 Flex 调试器中调试 TestVO 对象时,我得到:

test1 数组(@597d779)
test2 数组(@597d779)

即:它们引用相同的数组对象。

如果我从远程服务器发送的 2 个数组的值略有不同:

$this->test1 = array("foo", "bar");
$this->test2 = array("bar", "foo");

在 Flex 调试器中,TestVO 对象现在有两个单独的数组,正如您所期望的:

test1 数组(@54cb7e9)
test2 数组(@54cb741)

AMF 输出看起来不错,它总是为 test1/test2 发送两个单独的值,即使它们具有相同的值,所以我猜这是 Flex 反序列化的方式?

有任何想法吗?谢谢。

4

2 回答 2

2

AMF 这样做是为了在电线上获得一些压缩。如果您不想要这个,那么您可以切换到 AMF0 格式而不是 AMF3。但我不确定如何使用 ZendAMF 做到这一点。

于 2009-11-11T12:36:09.510 回答
0

在 AMF 的 Zend Framework 实现上发现错误 ZF-7634。它正在错误地序列化数组。

http://framework.zend.com/issues/browse/ZF-7634

于 2009-11-12T11:15:15.667 回答