Firebase database import JSON

1,034 views
Skip to first unread message

sdfw09

unread,
Sep 30, 2016, 11:03:13 AM9/30/16
to Firebase Google Group
Hi,

I have imported a JSOn file into firebase database using "import JSON" option.
In the JSON i have  key value pair in particular order which suits my application.
But after import, i see that the database has all the data sorted alphabatically by key.
So I had below structure in my original JSON,
"f" : "1"
"a" : "hi"

After import, in the database it shows as
"a" : "hi"
"f" : "1"

Since it is sorted, when I query from application, i get the data in alphabatical order which makes it difficult for me to use.

Any idea why firebase sorts automatically after JSON is imported? and How to prevent it from sorting?

Thanks.

Kato Richardson

unread,
Oct 4, 2016, 10:56:05 AM10/4/16
to Firebase Google Group
There must be more than you've shared here. It's going to be hard to be any assistance without a) a minimal repro that shows how you're saving the data and b) a realistic representation of your data (since values changing keys isn't actually possible, this can't be accurate).

☼, Kato

P.S. If it's not offensive to your culture or beliefs, I'd encourage you to introduce yourself! We are a close-knit family. It's easier to keep that culture strong when we remember that there are real people on the other end of our emails. Getting to know one another by name is a great first step.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/ada6bc46-e3e5-418d-8caa-694400cfcff7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Michael Bleigh

unread,
Oct 4, 2016, 11:00:49 AM10/4/16
to Firebase Google Group

JSON objects must always be considered unordered. Though many parser implementations keep the order by convention or chance, this is never guaranteed.

Firebase sorts by key by default and with queries can sort by value or by a child node's value.


On Tue, Oct 4, 2016, 7:56 AM 'Kato Richardson' via Firebase Google Group <fireba...@googlegroups.com> wrote:
There must be more than you've shared here. It's going to be hard to be any assistance without a) a minimal repro that shows how you're saving the data and b) a realistic representation of your data (since values changing keys isn't actually possible, this can't be accurate).

☼, Kato

P.S. If it's not offensive to your culture or beliefs, I'd encourage you to introduce yourself! We are a close-knit family. It's easier to keep that culture strong when we remember that there are real people on the other end of our emails. Getting to know one another by name is a great first step.
On Thu, Sep 29, 2016 at 5:12 PM, sdfw09 <zee...@gmail.com> wrote:
Hi,

I have imported a JSOn file into firebase database using "import JSON" option.
In the JSON i have  key value pair in particular order which suits my application.
But after import, i see that the database has all the data sorted alphabatically by key.
So I had below structure in my original JSON,
"f" : "1"
"a" : "hi"

After import, in the database it shows as
"a" : "hi"
"f" : "1"

Since it is sorted, when I query from application, i get the data in alphabatical order which makes it difficult for me to use.

Any idea why firebase sorts automatically after JSON is imported? and How to prevent it from sorting?

Thanks.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/ada6bc46-e3e5-418d-8caa-694400cfcff7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages