However, on the cloud code, I could not managed to insert that JSON document into the collection "MyCollection"
var collectionName = Spark.getData().MY_COLLECTION
var doc = Spark.getData().MY_DOCUMENT
var collection = Spark.runtimeCollection(collectionName);
collection.insert(doc)
The error I get is
Cannot convert to org.mozilla.javascript.NativeObject (299640-event-MY_EVENT_NAME#10)
Note: I've changed the code to describe the problem clearly.
Best Answer
C
Customer Support
said
about 6 years ago
Hi Adrian,
You might try stringify it on the server side, than replace out all the non valid characters, seems to be mainly the backslashes, than parse it to JSON.
This problem you are having is happening as a result of JsonUtility.ToJson(myObject), use GSDataRequest instead, you can see the documentation with an example here.
Hope this helps,
- Tony.
A
Adrian Gomez
said
about 6 years ago
I am having the same issue. Unfortunately, I don't control how the request is sent. Is there anything I can do on the GameSparks side? Here is my error:
"error": "Cannot convert {\"Properties\":[],\"Name\":\"\",\"Children\":[{\"Properties\":[{\"Name\":\"rowCount\",\"Value\":1},{\"Name\":\"columnCount\",\"Value\":13},{\"Name\":\"0-1-name\",\"Value\":\"gameId\"},{\"Name\":\"0-1-type\",\"Value\":1},{\"Name\":\"0-2-name\",\"Value\":\"playerOne\"},{\"Name\":\"0-2-type\",\"Value\":1},{\"Name\":\"0-3-name\",\"Value\":\"playerTwo\"},{\"Name\":\"0-3-type\",\"Value\":1},{\"Name\":\"0-4-name\",\"Value\":\"move1\"},{\"Name\":\"0-4-type\",\"Value\":2},{\"Name\":\"0-5-name\",\"Value\":\"move2\"},{\"Name\":\"0-5-type\",\"Value\":2},{\"Name\":\"0-6-name\",\"Value\":\"move3\"},{\"Name\":\"0-6-type\",\"Value\":2},{\"Name\":\"0-7-name\",\"Value\":\"move4\"},{\"Name\":\"0-7-type\",\"Value\":2},{\"Name\":\"0-8-name\",\"Value\":\"move5\"},{\"Name\":\"0-8-type\",\"Value\":2},{\"Name\":\"0-9-name\",\"Value\":\"move6\"},{\"Name\":\"0-9-type\",\"Value\":2},{\"Name\":\"0-10-name\",\"Value\":\"move7\"},{\"Name\":\"0-10-type\",\"Value\":2},{\"Name\":\"0-11-name\",\"Value\":\"move8\"},{\"Name\":\"0-11-type\",\"Value\":2},{\"Name\":\"0-12-name\",\"Value\":\"move9\"},{\"Name\":\"0-12-type\",\"Value\":2},{\"Name\":\"0-13-name\",\"Value\":\"status\"},{\"Name\":\"0-13-type\",\"Value\":2}],\"Name\":\"id731395_headers\",\"Children\":[]},{\"Properties\":[{\"Name\":\"1\",\"Value\":\"|345|w2343|w23456|2|0|0|0|0|0|0|0|0|0|\"}],\"Name\":\"id731395\",\"Children\":[]}]} to org.mozilla.javascript.NativeObject (callbacks/multiplayer.js#11)",
Customer Support
said
about 6 years ago
Answer
Hi Adrian,
You might try stringify it on the server side, than replace out all the non valid characters, seems to be mainly the backslashes, than parse it to JSON.
Ali Burak Kulakli
Hello,
There is an object I want to add into a collection on Unity. I created a JSON from that object with this code and tried to send an event.
However, on the cloud code, I could not managed to insert that JSON document into the collection "MyCollection"
The error I get is
Note: I've changed the code to describe the problem clearly.
Hi Adrian,
You might try stringify it on the server side, than replace out all the non valid characters, seems to be mainly the backslashes, than parse it to JSON.
Hope this helps,
- Steve
1 person has this question
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Ali,
This problem you are having is happening as a result of JsonUtility.ToJson(myObject), use GSDataRequest instead, you can see the documentation with an example here.
Hope this helps,
- Tony.
Adrian Gomez
I am having the same issue. Unfortunately, I don't control how the request is sent. Is there anything I can do on the GameSparks side? Here is my error:
Customer Support
Hi Adrian,
You might try stringify it on the server side, than replace out all the non valid characters, seems to be mainly the backslashes, than parse it to JSON.
Hope this helps,
- Steve
Customer Support
https://docs.gamesparks.com/tutorials/database-access-and-cloud-storage/c-sharp-object-serialization-for-gamesparks.html
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics