简体   繁体   English

克服很长的JSON字符串?

[英]Overcoming a Very Long JSON String?

I am trying to build a weekly schedule, and I want to make an Android app to display it. 我正在尝试建立每周时间表,并且想制作一个Android应用程序来显示它。

I have to send a Week object that contains a list of days, which contains a list of hours, which contains a list of events. 我必须发送一个Week对象,其中包含天列表,其中包含小时列表,其中包含事件列表。

Every event has multiple variables. 每个事件都有多个变量。

The data comes from a local database I built on my PC, and on the app I set a GUI friendly query which returns the planned week in a JSON format. 数据来自我在PC上构建的本地数据库,并且在应用程序上设置了GUI友好查询,该查询以JSON格式返回计划的星期。

Now that JSON has become 2000 lines long on the best case, and around 5000 lines worst case. 现在,在最好的情况下,JSON已变成2000行长,而在最坏的情况下则变为5000行左右。

Any suggestions on how I can handle this? 关于如何处理此问题的任何建议?

Another problem is that the JSON comes back in packets, so I cannot parse parts on it until I receive it fully, and Java cannot handle such long strings. 另一个问题是JSON以数据包的形式返回,因此在完全接收到它之前,我无法解析其部分,而Java无法处理如此长的字符串。

I would suggest you to use Firebase as your database. 我建议您使用Firebase作为数据库。 Firebase is a cloud database which can be accessed by web and android app also. Firebase是一个云数据库,也可以通过Web和android应用程序进行访问。 The data is kept synced at all times so you do not need to fire a different query in your app. 数据始终保持同步,因此您无需在应用中触发其他查询。

Just store the data in Firebase from your pc and access it via android app and display it. 只需将数据从您的PC存储在Firebase中,然后通过android应用访问并显示它。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM