如何正确返回作为JSON-ified版本的Parse对象?

时间:2018-06-05 20:08:36

标签: objective-c parse-platform

我在我的服务器上点击自定义函数,在我的PFObject对象中获得Convos并从JS返回该对象,这会在我的Objective-C代码中生成此字符串:

"<convos: 0x6080002ae220, objectId: e1VYAIFCyQ, localId: (null)> { \n buyerDeleted = NO;\n buyerId = NNfjWZrk8r;\n buyerPicture = \"<PFFile: 0x60800065de80>\";\n buyerSentMessage = YES;\n buyerSentTwoMessages = YES;\n buyerUnseen = 0;\n buyerUser = \"<PFUser: 0x6080002f1900, objectId: NNfjWZrk8r, localId: (null)>\";\n buyerUsername = corby;\n convoId = bQLQWNEtwmNNfjWZrk8r;\n lastSent = \"<messages: 0x60c0000b8600, objectId: iYVIjJ6A3q, localId: (null)>\";\n lastSentDate = \"2018-06-05 19:09:52 +0000\";\n profileConvo = YES;\n sellerDeleted = NO;\n sellerId = bQLQWNEtwm;\n sellerSentMessage = YES;\n sellerUnseen = 0;\n sellerUser = \"<PFUser: 0x6080002f1a80, objectId: bQLQWNEtwm, localId: (null)>\";\n sellerUsername = tough;\n source = profile;\n totalMessages = 3;\n }"

我试图在我的JS中使用convo对象并在其上运行convo.toJSON()(这似乎是解决方案)然后返回它,但这似乎需要很长时间

有关如何返回该Parse对象的任何提示,以便我最终可以将其转换为客户端中的NSDictionaryPFObject吗?

1 个答案:

答案 0 :(得分:0)

我认为我们让你感到松懈,但是对于其他发现这一点的人来说:

请勿使用服务器中的toJSON(),只需返回Parse.Object

即可

在您的Obj-C代码中,将此行添加到回叫的成功块中: PFObject *resultParseObject = (PFObject*)object,其中object是云函数回调的_Nullable id object参数。