Basic Javascript Examples — Part 3

Creating object, parsing JSON and simple assertion in Postman

Ceren Çakır
Jan 29, 2024

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! :)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Ceren Çakır
Ceren Çakır

No responses yet

Write a response