Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davenaugler/unit_14_restjson
This is a description
https://github.com/davenaugler/unit_14_restjson
jackson-databind java maven spring-boot
Last synced: about 2 months ago
JSON representation
This is a description
- Host: GitHub
- URL: https://github.com/davenaugler/unit_14_restjson
- Owner: davenaugler
- License: mit
- Created: 2024-01-02T22:53:15.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-17T20:46:16.000Z (12 months ago)
- Last Synced: 2024-01-19T00:41:23.834Z (12 months ago)
- Topics: jackson-databind, java, maven, spring-boot
- Language: Java
- Homepage:
- Size: 84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unit_14-Rest-JSON
## 01 - JSON
- Created `JsonExample.java` and broke down how JSON looks and how it is structured.
- JSON is based on Key Value pairs
- Objects are represented by curly brackets `{}`
- Arrays are represented by square brackets `[]`## 02 - Converting JSON Strings to Java and Back
- Downloading someone else's code. In this case it's within our Spring-Boot Maven project (Jackson databind).
- Task: Take a Java Object and convert it into a JSON String and then visa versa
- Used [Jackson databind](https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind) to perform the local lifecycle of a JSON String, modify the JSON, and ouput the JSON String## 03 - Sending Data to Java via Post Request
- Learned to pass data from a web request, using Postman
- Put `@RequestParam`'s within the `createPerson` class.
- Made `gender` optional by adding `@RequestParam(required = false)`
- Status: 200 OK
- Doing it this way we sent `name`, `age`, and `gender` via Query Params through the ULR
- Doing this exposes our data
- **Pros:** Quick and easy, stateless, and there's no need for session management
- **Cons:** Security risks, data size limitations, caching issues, and unpleasant user experience## 04 - Omitting RequestParam Annotation
- Removed the `@RequestParam` annotations within the `createPerson` class
- Class still successfully runs and returns us our object as it did before within the URL
- Feature of doing it this way is that you can not specify required fields.
- Doing it this way, none of the fields within the `createPerson` class are required.
- So if you leave out `age` it's totally fine and returns `age` as null
- Status: 200 OK## 05 - Request Header and Body
- Learning the difference between sending data via URL and sending data within the Body of the request via POST
- GET Request: Getting data from the server to HTML
- POST Request: Sending data from HTML to the server (using the Body of the Post request to send the data)## 06 - Path Variables
- Sending path variables through GET request using Postman## 07 - Mocking a Repository
- Come back to## 08 - Rest Calls with Spring
- Went to [Alpha Vantage](https://www.alphavantage.co/) to play with their free API Key
- Reviewed their documentation## 09 - Mapping JSON Response to Java Objects