This week's book giveaways are in the Jython/Python and Object-Oriented programming forums. We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line! See this thread and this one for details.
And it looks like you want to create more than one row in your table, based on what I see in your JSON data. But your code only creates one.
Fortunately you just asked the same question about your Java code creating only one object instead of a list of different objects. The answer to that question is the answer to this question too.
posted 1 month ago
The issue I'm having understanding your help is that when my code looked like this:
And there was only one record in the database, it worked fine. I could parse the JSON string and it wasn't an issue. Now I can't figure how to loop through the data. I have multiple records in my database so when I say table_values.id it can't decipher between which id I'm referring to.
Andrew Spiteri wrote:His JSON looks like this at the beginning: I'm not sure how'd you make Java do that, though. This is what my servlet code looks like ...
This isn't exactly the same, but here's an example of how you could use the mapper to create the structure that looks like this:
Structure the data with Java object to represent the structure of the JSON data, and then pass the mapper the the top-level element to serialize:
Data classes I used for example:
Also, since the value of completed provided by the server could be null, you should guard against interpreting that value as representing time otherwise you may find that your table show something January 1, 1970, which is obviously wrong.
Maybe something like this:
posted 1 month ago
Thanks for your help. I really need to learn more about ObjectMapper and how it works to get a grasp of what I just did.
My trainer sent me some stuff from Baeldung on ObjectMapper I have yet to read, from before we dove into servlets. I guess I'll be doing that when I get some time.
Maybe focus on the front-end first and get the data representation and rendering figured-out first, and then move on to the back-end.
For example - start with putting the data inside your table rendering function and get that to work, then provide the the data from another function or a command-line tool (such as netcat) which could mock what the backend would send, then move on to actually getting from the back-end.
This is what I see on my browser (I didn't apply any styling):
Look! It's Leonardo da Vinci! And he brought a tiny ad!