简体   繁体   English

freepascal:JSON和递归数据结构

[英]freepascal: JSON and recursive data structure

Can fpjson handle load AND save of the following structure from/to json: fpjson可以处理负载并从json保存以下结构:

PTreeStructure = ^TTreeStructure;
TTreeStructure = class
  name: string;
  value: Integer;
  items: array of PTreeStructure;
end;

Thanks! 谢谢!

fcl-json can store nested data (an object can have an array of objects, which can have an array of objects, see the supplied examples) fcl-json可以存储嵌套数据(一个对象可以具有一个对象数组,该对象可以具有一个对象数组,请参见提供的示例)

But that way you store the objects themselves, not the references, which is fine for a tree, but not for cycling structures. 但是这样一来,您就可以存储对象本身,而不是引用,这对于树而言是合适的,但对于循环结构而言则不是。

A DAG can be represented by storing a flat array with all data, but store items with indexes or some form of unique ID per record into the array instead of pointers. DAG可以通过存储包含所有数据的平面数组来表示,但可以将具有每个记录的索引或某种形式的唯一ID的项存储到数组中,而不是指针。

If your root isn't the first element, you need to additionally store the index/iD of the root somewhere 如果您的根目录不是第一个元素,则需要另外将根目录的索引/ iD存储在某个位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM