- Home /
ArgumentException: JSON ArgumentException: JSON must represent an object type.
I am trying a small Unity application in which the user can enter the Id and name and when he clicks submit button the data gets stored into the Firebase database and when the search button is clicked the data is retrieved from the database.The data is being store but when i try to retrieve the data i face the issue: ArgumentException: JSON must represent an object type. UnityEngine.JsonUtility.FromJson (System.String json, System.Type type) (at C:/buildslave/unity/build/Modules/JSONSerialize/Public/JsonUtility.bindings.cs:50) UnityEngine.JsonUtility.FromJson[T] (System.String json) (at C:/buildslave/unity/build/Modules/JSONSerialize/Public/JsonUtility.bindings.cs:33) Proyecto26.HttpBase+<>c_DisplayClass5_0`1[TResponse].b0 (Proyecto26.RequestException err, Proyecto26.ResponseHelper res) (at Assets/RestClient/Packages/Proyecto26.RestClient/Utils/HttpBase.cs:89) Proyecto26.HttpBase+d_0.MoveNext () (at Assets/RestClient/Packages/Proyecto26.RestClient/Utils/HttpBase.cs:24) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
The below is the file where i add and retrieve the data
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using Proyecto26;
public class DbTest : MonoBehaviour { public Text Iddispl; public Text Namedispl;
public InputField Nameentr;
public InputField Identer;
Worker worker = new Worker();
public static string id;
public static string Name;
public void OnSubmit() { Name = Nameentr.text; id =Identer.text.ToString(); DbSubmit(); } public void DbSubmit() { Worker worker = new Worker(); RestClient.Put("https://dbtest-49c15.firebaseio.com/"+Name+".json",worker); } public void OnRetrive() { Dbretrive(); }
private void Display()
{
Iddispl.text ="id:"+ worker.Wid;
Namedispl.text ="Welcome "+worker.Wname;
}
public void Dbretrive()
{
RestClient.Get<Worker>("https://dbtest-49c15.firebaseio.com/" + Namedispl.text + ".json").Then(response =>
{
worker = response;
Display();
});
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612192145im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Sync with visual studio 2010 error 1 Answer
No Monobehaviour scripts in files 1 Answer
2-Dimensional Array Error [CLOSED] 1 Answer