Basic Javascript Examples — Part 3
Creating object, parsing JSON and simple assertion in Postman
We’re creating an object called ‘person’. This object has different properties like name, age.
Here, we are parsing JSON. To get JSON string, Javascript object is serialized and it’s done with JSON.stringfy(person). But when we want to get a Javascript object from JSON string, JSON.parse(serializedObejct) is used. JSON is just a way of transferring data. When we’re working with API’s, we are not receving JS, we are not sending JS. We are just working with JSON.
Response is our object and status is it’s property. To get the value of property, response.status is written. As we can see here, the test failed. Because we are expecting response’s status as ‘DOWN’. But the response’s status is actually ‘UP’. So, we did check assertion simply.
Have a nice testing day! :)