Store JSON in an sqlite field?

前端 未结 1 639
悲哀的现实
悲哀的现实 2021-01-18 10:09

I\'m writing an application that communicates with a web API, which responds with JSON. Currently, I\'m translating the JSON objects to Java objects using gson (which is awe

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-18 10:48

    The main thing I wouldn't like about it is relying on the structure of the stored/retrieved JSON to be valid, since it's completely out of the hands of the database. Not that you can't take precautions against possible issues, but if the JSON is somehow truncated or otherwise compromised in a way that trips up the parser, you're then missing the entire object instead of just one invalid or truncated property. If that's an acceptable risk, then it's probably a reasonable technique.

    0 讨论(0)
提交回复
热议问题