如何在Json文件中导出/保存DataSnapshot Firebase?

时间:2017-01-12 20:39:35

标签: android json firebase firebase-realtime-database

我有很大的问题。我的Firebase中有这个结构:

my Firebase structure

我想将这个结构保存在JSON文件/ String中无论如何。我会得到这样的结果:

{
"-Ka8_NYNxaFCcZQ3eaTp" : {
  "Persons" : {
    "-KaHUTUan-l06OVjsUlu" : {
      "birthDay" : "13.01.2017",
      "deathDay" : "06.01.2017",
      "lastName" : "LastName1",
      "latitude" : "54.2039383",
      "longitude" : "16.1930868",
      "name" : "name1"
    },
    "-KaHU_nPOE2NlqTbhLxT" : {
      "birthDay" : "11.01.2017",
      "deathDay" : "03.01.2017",
      "lastName" : "LastName2",
      "latitude" : "54.2039383",
      "longitude" : "16.1930868",
      "name" : "name2"
    }

  },
  "city" : "Wroclaw",
  "county" : "county1",
  "nameCemetery" : "nameCemetery1",
  "province" : "province1",
  "street" : "street1"
}

我尝试过DataSnaphot,但结果不是JSON格式,例如:

{-Ka8_NYNxaFCcZQ3eaTp={nameCemetery=nameCemetery1, street=street1, county=county1, province=province1, Persons={-KaHU_nPOE2NlqTbhLxT={name=Damian, latitude=54.2039383, lastName=Szeeczyk, birthDay=11.01.2017, longitude=16.1930868, deathDay=03.01.2017}, -KaHUTUan-l06OVjsUlu={name=name1, latitude=54.2039383, lastName=LastName1, birthDay=13.01.2017, longitude=16.1930868, deathDay=06.01.2017}}, city=Wroclaw}}

对我来说最重要的不是创建JSONArray人,因为那时我的应用程序将运行不正确。 简而言之,我想创建一个复制节点(在我的示例中为键 - " Ka8_NYNxaFCcZQ3eaTp"

0 个答案:

没有答案