【发布时间】:2018-03-15 21:57:33
【问题描述】:
我在我的 react-native 应用程序中定义了嵌套领域对象:
export const userSchema = {
name: 'User',
primaryKey: 'id',
properties: {
id: 'string',
user_id: 'string',
password: 'string',
demographics: 'Demographics',
notes: 'string'
}
}
export const demographicsSchema = {
name: 'Demographics',
primaryKey: 'id',
properties: {
id: 'int',
age: 'int',
height: 'float',
weight: 'float',
gender: 'int',
}
}
当我从领域查询User 时,我想将其转换为Json 并通过http 请求发送到后端服务器。但是,在搜索将领域对象转换为 Json 的模块后,我没有找到任何有用的内容来执行此特定任务。如果有人知道在 react-native 中将嵌套领域对象转换为 Json 的简单方法,我将不胜感激。
【问题讨论】:
-
它是一个嵌套对象,我想你应该看看这个问题stackoverflow.com/questions/30174970/…
-
@AbdeslemCharif 不是我要找的,realmObject 是不同的。
-
它们与嵌套对象有什么不同?
-
@AbdeslemCharif 是的,我特别要求将 realmObject 序列化为 Json。如果要使用
gson,至少要知道字符串结构是什么样子的。
标签: javascript react-native realm