Storing list in a dictionary

0 votes
I have a question regarding the storage of json documents in the No SQL storage service. What is the exact method to store a List of strings as a value in a json document? I am getting a Bad Parameter exception error every time I try t o add a list as a value in the dictionary json objet by the save and update callback method. This is how I did it
 
jsonObjectMatch.Add ("self", FB.UserId);
 
jsonObjectMatch.Add ("opID", matchColOpID);
 
jsonObjectMatch.Add ("opName", matchColOpName);
 
storageService.SaveOrUpdateDocumentByKeyValue (database, matchCollection, "self", key, jsonObjectMatch, new UnitySaveUpdateCallback ());
 
The exception is as follows:
 
appErrorCode : "1400"
 
Exception : com.shephertz.app42.paas.sdk.csharp.App42BadParameterException: {"httpErrorCode":"400", "appErrorCode":"1400", "message":"Bad Request", "details":"The Request parameters are invalid"}
UnityEngine.Debug:Log(Object)
com.shephertz.app42.paas.sdk.csharp.App42Log:Console(String)
UnitySaveUpdateCallback:OnException(Exception) (at Assets/Scripts/UnitySaveUpdateCallback.cs:33)

 

asked Jun 26, 2014 in App42PaaS & BPaaS by codeandart.games (21 points)
Are you trying to add the array in respective keys or just simple json string in Storage Object ?
matchColOpID and matchColOpName are lists of strings, added to keys opID and opName keys as lists (not json strings).

1 Answer

0 votes
 
Best answer

Hi,

For that you can add a Ilist as explained below:

IList<string> name = new List<string>();
name.Add("Nick");
name.Add("Pamila");
JArray usersArray = new JArray ();
for (int i = 0; i < name.Count; i++) {
String currentUser = (String)name[i];
     usersArray.Add (currentUser.ToString());
}
 
Dictionary<String, object> jsonObjectMatch = new Dictionary<String, object>();  
jsonObjectMatch.Add ("opName", usersArray);
 
Let me know if it will works for you or need any other assitance regarding this.
 
Thanks.
answered Jun 26, 2014 by hs00105 (517 points)
selected Jun 26, 2014 by codeandart.games
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com