There is, for example, a site that gives a list of posts (title, date, image and post ID) in json format (for example: http://siteexample.com/apisite/pic.php?task=1&post=200 (here we get 200 New / recent news.) Parse no problem (very simple json). But you need to get new posts / news (there is no offset and no different lotions, only as in the example above). How to do it, i.e. not interested code, and the algorithm. Direct the path true. Thank you.
- The link you brought does not work in the sense that JSON is not given over it - AlexThumb
- This link is just an example. - iSerg
|
1 answer
Each post as you mentioned contains some id by which it can be uniquely identified. When parsing a new JSON, check if there is a specific value already in the database. If yes, go by, if not - add to the database and refresh the view on which you are outputting the data. If the post id is not auto-increment, then in order to have the order of posts, start this field with the entity in which you store this data. When parsing, assign auto-increment values to new entities. Thus, you will be able to sort the data and have the number of the last post by which you can check the data upon entry.
- Yes, there is an ID. And it is incremented, for example: "ID": 230647, "ID": 230538. those. sorting by descending posts. In principle, everything is logical. You can in one of the fields / column cord, add this Aidi. The algorithm is as follows: 1. When you restart the application, take the last post from the database (which is added). 2. Add posts (json-dikshinari objects) to the array until we meet the post with the last ID taken from the database. 3. Add these objects to the database already in sorted form. Something like this. Thank. - iSerg
- You all correctly described. To health! - AlexThumb
|