Learn how to access JSON passed parameters using Kitura. Watch a demonstration of how JSON data can be mapped to model classes.
- Kitura leverages swifty JSON…library to parse JSON requests.…In order to send JSON post requests,…we will also use POSTMAN, which is a…free tool for making networking requests.…We will start by importing the SwiftyJSON library.…Simply say import SwiftyJSON.…Now, we are going to create a new route,…which will be responsible for returning the dishes…based on the course that has passed.…
Let's call that route dishes by course, Router.post…and the name of the route will be dishes by course.…It will consist of three parameters,…which will be request, response, and of course, next.…
Inside our endpoint dishes by course,…we are going to extract the body from the request.…We will start by saying, guard let parsedBody.…The body of the request is inside request dot body,…so we are simply going to use that.…However, if body is not found,…then we can end the response by saying response dot status,…it's a bad request, and then ending the response.…
However, if the body was found,…then we are going to check if the body…can be converted into a JSON object.…
Released
1/5/2018- Reviewing the concepts behind server-side Swift programming
- Different server-side Swift frameworks
- Setting up a Kitura project
- Adding HeliumLogger for debugging
- Accessing JSON passed parameters using Kitura.
- Reading URL parameters and URL encoded form parameters
- Configuring the PostgreSQL database
- Fetching, inserting, and deleting records from the database
- Integrating a Kitura API with an iPhone app
Share this video
Embed this video
Video: Reading JSON