【问题标题】:Getting json data from realtime database从实时数据库中获取 json 数据
【发布时间】:2020-11-05 23:38:43
【问题描述】:

我正在使用带有统一 c# 的 firebase 我存储了一个 JSON 对象(英雄),然后当我尝试检索该对象时,它以与之前不同的顺序返回 JSON 值,我不知道这是否是错误的原因,但是当我尝试解析时它返回到对象永远不会起作用
为什么会这样

       public class hero1 : ScriptableObject
{
    public string heroname;
    public string treasure;
    public string[] jewel;
    public float hp;
    public float dps;
    public float def;
    public float spd;
    public float skillvalue;
    public string skilltype;
    public string passivetype;
    public int level;
    public int rank;
    public string type;
    public int starlevel;
    public float totalstats;

}```

this is the hero object that is saved

  heroes.stringo[x] = heroes1.stringo[x];
  storer2 = (heroes1.stringo[x]);   
          reference.Child("users").Child(server.stringo[0].ToString()).Child("heroes").Child(herohchildnames[x].ToString()).SetRawJsonValueAsync(storer2).ContinueWithOnMainThread(task =>```

就是这样保存的

  heroes1.stringo[x] =snapshot.Child("heroes").Child(herohchildnames[x].ToString()).GetRawJsonValue();
                    Debug.Log(snapshot.Child("heroes").Child(herohchildnames[x].ToString()).GetRawJsonValue());

这就是它的回调方式

【问题讨论】:

  • 请不要描述你的代码。相反,请将您的问题编辑为包含minimal, complete/standalone code with which anyone can reproduce the problem
  • 欢迎来到 StackOverflow,尽管我确信您的问题对您来说非常有意义。它缺乏适合我们的信息。有时你需要记住我们是完全陌生的,我们不能调试一个故事。你越善于解释你的问题,我们就能更快地给你答案(或不给你答案)

标签: c# json unity3d firebase-realtime-database


【解决方案1】:

为了回答这个问题,我将数据解析为一个不同的对象,该对象与发送的原始对象具有相同的属性

【讨论】:

    猜你喜欢
    • 2019-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-04
    • 2021-03-10
    • 1970-01-01
    • 2019-07-12
    • 2019-09-30
    相关资源
    最近更新 更多