# JSON parse error: Unexpected character ('n' (code 110)): was expecting comma to separate Object entries

**URL:** <https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [December 2, 2019, 6:09pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035 "2019-12-02T18:09:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![arild.andreassen](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@arild.andreassen](https://forum.katalon.com/u/arild.andreassen)\
**Post date:** [December 2, 2019, 6:09pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/1 "2019-12-02T18:09:02Z")

</div>

We have a test where we pass a JSON object to an endpoint object. The object created in katalon studio passed the JSON object right on through to the endpoint

This test is passing when run in Katalon 6.3.0.rc7, but if we run it in Katalon 6.3.3 it fails with the error message

```
JSON parse error: Unexpected character ('n' (code 110)): was expecting comma to separate Object entries

```

To be clear, the enpoint of our microservice is throwing this error, and Katalon fails the test when the api call returns a 400 instead of a 200…

To me it looks like the message being sent to the endpoint is not identical. It seems extra characters are being added to the request object before it leaves Katalon.  
Is anyone experiencing this problem?  
Is there a way to have the request object printed out so I can see what is actually being sent?

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [December 2, 2019, 6:14pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/2 "2019-12-02T18:14:15Z")

</div>

> [@arild.andreassen](#):
>
> Is there a way to have the request object printed out so I can see what is actually being sent?

You can see requests and their properties in the **[DevTools Network](http://forum.katalon.com/t/how-to-the-browser-developer-tools-f12-devtools/34329/)** panel.

You should consider upgrading to the latest release.

---

<div class="post-metadata">

**Author:** ![Ibus](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@Ibus](https://forum.katalon.com/u/Ibus)\
**Post date:** [December 2, 2019, 6:59pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/3 "2019-12-02T18:59:08Z")

</div>

> [@arild.andreassen](#):
>
> To be clear, the enpoint of our microservice is throwing this error, and Katalon fails the test when the api call returns a 400 instead of a 200

what else would you expect?  
i suggest to add a verification (or two) in katalon before any attempt to parse the response:

- response code 200
- response is json

---

<div class="post-metadata">

**Author:** ![arild.andreassen](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@arild.andreassen](https://forum.katalon.com/u/arild.andreassen)\
**Post date:** [December 2, 2019, 9:24pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/4 "2019-12-02T21:24:00Z")

</div>

The problem is that the test passes with a 200 in 6.3.0, but i get a 400 in 6.3.3.  
Nothing else changes. The test does not change, so I would not expect a different result

---

<div class="post-metadata">

**Author:** ![arild.andreassen](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@arild.andreassen](https://forum.katalon.com/u/arild.andreassen)\
**Post date:** [December 2, 2019, 9:27pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/5 "2019-12-02T21:27:08Z")

</div>

it’s not a request that goes through the browser.  
It goes from katalon directly to the microservice.

Upgrading might be an option down the road, but my company is currently using 6.3.3 across the board.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [December 2, 2019, 9:37pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/6 "2019-12-02T21:37:14Z")

</div>

> [@arild.andreassen](#):
>
> it’s not a request that goes through the browser.  
> It goes from katalon directly to the microservice.

My bad. I test all my services through the browser and keep forgetting how Katalon WS calls are made.

Wireshark? Fiddler?

---

<div class="post-metadata">

**Author:** ![Ibus](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@Ibus](https://forum.katalon.com/u/Ibus)\
**Post date:** [December 3, 2019, 6:03am UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/7 "2019-12-03T06:03:41Z")

</div>

> [@arild.andreassen](#):
>
> The problem is that the test passes with a 200 in 6.3.0, but i get a 400 in 6.3.3.

this is why I suggested that **always** to check for response code, before to attempt to parse the json, to avoid code crashes.

Now, to the issue … how does the URL of your API request looks like? Does contain special (escaped) characters?  
If it is a POST … can you show us the body too?  
Can you share also the .har file generated by the request?

---

<div class="post-metadata">

**Author:** ![arild.andreassen](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@arild.andreassen](https://forum.katalon.com/u/arild.andreassen)\
**Post date:** [December 3, 2019, 2:33pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/8 "2019-12-03T14:33:31Z")

</div>

The URL does not have any special characters,

> /api/ws-server/message

It is a POST, it does have escaped characters, and the body looks like below. (it is a constructed message in multiple layers, hence the various escapes)

> {  
> “topic”: “/topic/service/device/message”,  
> “message”: “{ "devices": [{ "deviceIndicator": "pts", "deviceDuiIndicator": "pts-gui", "deviceProperties":{ "DASSystemConfig": "{ \"name\": \"CPTS TestSystem\" }" }, "status": { "deviceIndicator": "pts", "status": "READY", "statusProperties":{ "DASSystemState": " { \"errorSignal\" : \"OK\", \"doNotLoad\": \"true\" }" }, "level": "READY" } }], "timestamp": "2019-12-03T14:02:07.971Z", "messageId": "e9265edb-c3e8-42e0-96c9-a826b418cd41", "messageClass": "DALDeviceInfoV1" }”  
> }

Sending this exact message through to the endpoint using the Object Repository results in a 200.  
But calling the endpoint from the test using WS returns the 400

> WS.sendRequest(findTestObject(‘websocket mock/send message’, [(‘url’) : GlobalVariable.WS\_MOCK\_URL, (‘message’) : msg]))

I don’t have a .har file

---

<div class="post-metadata">

**Author:** ![Ibus](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@Ibus](https://forum.katalon.com/u/Ibus)\
**Post date:** [December 3, 2019, 2:45pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/9 "2019-12-03T14:45:05Z")

</div>

> [@arild.andreassen](#):
>
> (‘message’) : msg]))

carefully check the content of this variable.  
the ‘n’ in the error response may indicate you have somewhere an undesired ‘not new line character’ (not properly escaped)

how is this variable produced? it is grabbed by a previous request or created in the script?

LE: to produce reliable Json bodies from the script code, a better approach is to use groovy SimpleTemplateEngine, instead of abusing escape’s (if parametrization is desired)

[http://docs.groovy-lang.org/docs/next/html/documentation/template-engines.html](http://docs.groovy-lang.org/docs/next/html/documentation/template-engines.html)

For simple plain bodies, use triple double quoted strings (Gstrings) (also Triple-single-quoted string may work for your case):

> **[GString (Groovy 4.0.15)](http://docs.groovy-lang.org/latest/html/api/groovy/lang/GString.html)**
>
> declaration: package: groovy.lang, class: GString

see: |Neither double quotes nor single quotes need be escaped in triple-double-quoted strings.|

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [December 3, 2019, 2:51pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/10 "2019-12-03T14:51:16Z")

</div>

@Ibus

> [@arild.andreassen](#):
>
> Unexpected character (‘n’ (code 110))

character 110 == ‘n’ not 10 = \n

---

<div class="post-metadata">

**Author:** ![Ibus](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@Ibus](https://forum.katalon.com/u/Ibus)\
**Post date:** [December 3, 2019, 2:53pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/11 "2019-12-03T14:53:22Z")

</div>

@Russ_Thomas thx for correction, i amended:

```auto
‘not new line character’ 

```

---

<div class="post-metadata">

**Author:** ![arild.andreassen](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@arild.andreassen](https://forum.katalon.com/u/arild.andreassen)\
**Post date:** [December 3, 2019, 3:03pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/12 "2019-12-03T15:03:38Z")

</div>

The content of the message is posted above. It does not vary.  
If we had extra escape characters in there, or the json was not properly formatted, would it not fail with both versions?

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [December 3, 2019, 3:06pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/13 "2019-12-03T15:06:58Z")

</div>

> [@arild.andreassen](#):
>
> would it not fail with both versions?

I agree. It certainly _sounds like_ there’s a parser issue between the two versions. However…

If that were the case, there would have been MANY similar reports from many users. There aren’t (weren’t) any, to my knowledge.

---

<div class="post-metadata">

**Author:** ![Ibus](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@Ibus](https://forum.katalon.com/u/Ibus)\
**Post date:** [December 3, 2019, 3:11pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/14 "2019-12-03T15:11:46Z")

</div>

> [@arild.andreassen](#):
>
> would it not fail with both versions

it may not.  
as far as i know there were various updates with regards how the escaping is working (in url’s, in bodies) during various versions … so better use proper and easy readable ways to produce your bodies.  
will help you to reduce flakiness

---

<div class="post-metadata">

**Author:** ![Jens.gr](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/jens.gr/32/7397_2.png) [@Jens.gr](https://forum.katalon.com/u/Jens.gr)\
**Post date:** [December 3, 2019, 3:41pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/15 "2019-12-03T15:41:51Z")

</div>

As it looks like you have “ and not " in your response. that would not be valid JSON

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [December 3, 2019, 5:33pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/16 "2019-12-03T17:33:07Z")

</div>

> [@Jens.gr](#):
>
> As it looks like you have “ and not " in your response. that would not be valid JSON

Where did you see that?

---

<div class="post-metadata">

**Author:** ![Jens.gr](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/jens.gr/32/7397_2.png) [@Jens.gr](https://forum.katalon.com/u/Jens.gr)\
**Post date:** [December 4, 2019, 7:48am UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/17 "2019-12-04T07:48:10Z")

</div>

I did Copy and past the json above to [http://json.parser.online.fr/](http://json.parser.online.fr/) to validate it, and it did say it right away 😉

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [December 4, 2019, 1:30pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/18 "2019-12-04T13:30:23Z")

</div>

> [@Jens.gr](#):
>
> I did Copy and past the json above

Take care with copy and paste from the forum. The forum ALWAYS messes with quotes - it’s very annoying.

Using the Crockford original, it’s perfectly valid.

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/0/0e5f4310eb8b41c764ab27239acab5b63a7cc68e.png)

---

<div class="post-metadata">

**Author:** ![Ibus](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@Ibus](https://forum.katalon.com/u/Ibus)\
**Post date:** [December 4, 2019, 2:40pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/19 "2019-12-04T14:40:13Z")

</div>

> [@Russ\_Thomas](#):
>
> The forum ALWAYS messes with quotes - it’s very annoying.

@Jens.gr

that’s why I always ask for properly formatted code **from the author source**.  
once pasted as regular text or quote-block, \> 50 % of the original code format is destroyed.

and you copy from the forum and paste again somewhere \> another source for errors. and so on …

---

<div class="post-metadata">

**Author:** ![Jens.gr](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/jens.gr/32/7397_2.png) [@Jens.gr](https://forum.katalon.com/u/Jens.gr)\
**Post date:** [December 4, 2019, 3:39pm UTC](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035/20 "2019-12-04T15:39:31Z")

</div>

Oh damn, good to know that messes with the sources

[Next page](https://forum.katalon.com/t/json-parse-error-unexpected-character-n-code-110-was-expecting-comma-to-separate-object-entries/37035.md?page=2)
