gpt4 book ai didi

json - 祝福对象转换为 JSON

转载 作者:行者123 更新时间:2023-12-05 07:43:29 25 4
gpt4 key购买 nike

如何在 Perl 中将受祝福的对象转换为 JSON?以下是我的数组:

@x = ({
'notificationtype' => 'TRAP',
'receivedfrom' => 'UDP: [10.127.34.212]:48909->[10.127.34.182]:162',
'version' => 1,
},
[
[
bless( {
'oidptr' => bless( do{\(my $o = '140059234062224)}, ''netsnmp_oidPtr' )
}, 'NetSNMP::OID' ),
'600',
67
],
[
bless( {
'oidptr' => bless( do{\(my $o = '140059236784112)}, ''netsnmp_oidPtr' )
}, 'NetSNMP::OID' ),
'OID: .iso.org.dod.internet.private.enterprises.14296.1.100.0.0.1',
6
]
]);

我可以使用 encode_json\@x 单独转换 $VAR1,但是当我使用 blessed 对象时,它不起作用。我收到错误:

encountered object 'NetSNMP::OID=HASH(0x136b278)', but neither allow_blessed nor convert_blessed settings are enabled at u.pl line 256.

我需要一个序列化的 JSON 对象,以便我可以将它发送到服务器。

我该怎么做?

最佳答案

视情况而定,您想保留视觉效果吗?还是数据和层次结构?其他终端尺寸无法呈现相同的位置。我会只保留数据和层次结构。可能我会忽略焦点和事件。我会开始 umarating 像下面这样的属性,然后创建一个工厂这些是我为 Box 找到的那些

container.options
container.position,
container.getLines()
container.getText()
container.getContent
container.children
container.parent
container.style
container.type
container.visible
container.height
container.hidden
container.index

子类有行、数据、线等等……我不认为有一种机械的方法来做到这一点……

如果您想重新创建层次结构,您还需要迭代子项和父项,可能是整个树。

考虑一下,也许仅使用 this.options 就足够了, child 和 parent .. 好运会尝试同样的...

关于json - 祝福对象转换为 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43654409/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com