简体   繁体   English

在锡耶纳坚持json

[英]persisting with json in Siena

Anyone persisted use the JSON format in Sinea? 有人坚持在Sinea中使用JSON格式吗?

http://www.sienaproject.com/documentation-json.html http://www.sienaproject.com/documentation-json.html

I need to persist collection fields where the collection is relatively small and contains only simple types like int, short, long, etc... Should I hack the field and make it String and write custom JSON code for each field? 我需要保留集合相对较小并且仅包含int,short,long等简单类型的集合字段。我应该修改该字段并将其设置为String并为每个字段编写自定义JSON代码吗? Should the property type become siena.Json instead of Collection? 属性类型应该变成siena.Json而不是Collection吗?

I guess the ideal scenario would be a JSON annotation (w/max length) for the collection letting Sinea know to serialize and serialize automatically. 我猜理想的情况是该集合的JSON注释(w /最大长度),让Sinea知道自动进行序列化和序列化。

Can you recommend a good way to code for this now? 您能推荐一种编码的好方法吗?

Just use @Embedded on the collection and Siena will use JSON automatically. 只需在集合上使用@ @Embedded ,Siena就会自动使用JSON。

See otherContacts example in : http://www.sienaproject.com/documentation-getting-started.html "2 fields contacts & otherContacts containing embedded data structures stored JSON serialized in the DB" 请参阅以下网站中的otherContacts示例: http : //www.sienaproject.com/documentation-getting-started.html “ 2字段联系人和其他联系人,其中包含存储在数据库中的JSON序列化的嵌入式数据结构”

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

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