[英]ParseObject: Is there any way how to create JSON from ParseObject?
I want to create JSON from ParseObject in my App. 我想在我的应用程序中从ParseObject创建JSON。 Usually If I need to pass object from one class to another, I pass
objectId
to bundle and I simply call query and return this object. 通常,如果我需要将对象从一个类传递到另一个类,则将
objectId
传递给bundle,然后简单地调用query并返回该对象。 Problem is if you create new ParseObject
in offline mode. 问题是,如果您以离线模式创建新的
ParseObject
。 Calling saveEventually
on new ParseObject
will not add objectId
. 调用
saveEventually
新ParseObject
不会增加objectId
。 ObjectId is null
that means I cant query object. ObjectId为
null
表示我无法查询对象。 The best way would be to send whole ParseObject
as String
to Bundle
and simply recreate it. 最好的方法是将整个
ParseObject
作为String
发送到Bundle
并简单地重新创建它。 This is how I worked with JSON
objects in past. 这就是我过去处理
JSON
对象的方式。 ParseObject.toString()
doesnt work as JSONObject
. ParseObject.toString()
用作JSONObject
。
Any suggestions? 有什么建议么?
You can call .toJSON() on a Parse Object. 您可以在解析对象上调用.toJSON()。
toJSON() → {Object}
Returns a JSON version of the object suitable for saving to Parse.toJSON() → {Object}
返回适合保存到Parse的对象的JSON版本。Returns: Type: Object
返回值:类型:对象
Source: http://parseplatform.org/Parse-SDK-JS/api/2.7.1/Parse.Object.html#toJSON 来源: http : //parseplatform.org/Parse-SDK-JS/api/2.7.1/Parse.Object.html#toJSON
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.