# How to check when I get response that it is in JSON format and to add validation

**URL:** <https://community.postman.com/t/how-to-check-when-i-get-response-that-it-is-in-json-format-and-to-add-validation/29317>\
**Category:** Help Hub\
**Created:** [November 2, 2021, 12:59pm UTC](https://community.postman.com/t/how-to-check-when-i-get-response-that-it-is-in-json-format-and-to-add-validation/29317 "2021-11-02T12:59:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![satellite-geoscient2](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@satellite-geoscient2](https://community.postman.com/u/satellite-geoscient2)\
**Post date:** [November 2, 2021, 12:59pm UTC](https://community.postman.com/t/how-to-check-when-i-get-response-that-it-is-in-json-format-and-to-add-validation/29317/1 "2021-11-02T12:59:33Z")

</div>

When I get the response I would like to check whether is in JSON presented and to add validation for true or false in the test.

---

<div class="post-metadata">

**Author:** ![cmnazario](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/cmnazario/32/10207_2.png) [@cmnazario](https://community.postman.com/u/cmnazario)\
**Post date:** [November 2, 2021, 4:28pm UTC](https://community.postman.com/t/how-to-check-when-i-get-response-that-it-is-in-json-format-and-to-add-validation/29317/2 "2021-11-02T16:28:24Z")

</div>

Hello @satellite-geoscient2 👋  
Welcome to the community 😊

I think you can check it that way 👇

```auto
const jsonData = pm.response.json();

pm.test("Check if response is json", function() {    
    pm.expect(jsonData).to.be.an('object');
});

```

---

<div class="post-metadata">

**Author:** ![sbettwieser](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/sbettwieser/32/13299_2.png) [@sbettwieser](https://community.postman.com/u/sbettwieser)\
**Post date:** [September 23, 2022, 9:21pm UTC](https://community.postman.com/t/how-to-check-when-i-get-response-that-it-is-in-json-format-and-to-add-validation/29317/3 "2022-09-23T21:21:57Z")

</div>

Hello, I tried doing this, but I got an error when the response was empty: `There was an error in evaluating the test script: JSONError: No data, empty input at 1:1 ^`

How can I factor that into my tests?
