# Unable to put json string into dictionary as a string

**URL:** <https://forum.robotframework.org/t/unable-to-put-json-string-into-dictionary-as-a-string/5406>\
**Category:** Robot Framework\
**Created:** [6 March 2023 13:30 UTC](https://forum.robotframework.org/t/unable-to-put-json-string-into-dictionary-as-a-string/5406 "2023-03-06T13:30:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![skyflash](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/skyflash/32/2406_2.png) [@skyflash](https://forum.robotframework.org/u/skyflash)\
**Post date:** [6 March 2023 13:30 UTC](https://forum.robotframework.org/t/unable-to-put-json-string-into-dictionary-as-a-string/5406/1 "2023-03-06T13:30:37Z")

</div>

I am trying to create a dictionary with some json content I want to try and the corresponding return status. It looks like this:

@{jsonlines}= Create Dictionary {"name": "RobotTestUser","firstname": "Rob","lastname": "Mc Robot","email": "mcrobot@email.de","roleid": 0} 400

(I also tried the syntax with =, didnt work either.)

The resulting dictionary does not have the 400 as a value, it just disappears.

Obviously it converts the “key” to a dictionary and ignores the rest.

So what am I doing wrong? I also tried escaping that json string, with , ‘’’  
, " and whatever else came to mind. Its still being converted. I just want it to take it as a string and put it into the key.

Thx for any help or advice!

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [7 March 2023 01:16 UTC](https://forum.robotframework.org/t/unable-to-put-json-string-into-dictionary-as-a-string/5406/2 "2023-03-07T01:16:27Z")

</div>

Hi @skyflash,

I’m curious where you were expecting the 400 to appear? As a Key or as a Value?

> [@skyflash](#):
>
> @{jsonlines}= Create Dictionary {“name”: “RobotTestUser”,“firstname”: “Rob”,“lastname”: “Mc Robot”,“email”: “[mcrobot@email.de](mailto:mcrobot@email.de)”,“roleid”: 0} 400

Let’s break this down:

> @{jsonlines}= Create Dictionary

You’ve called `Create Dictionary` and assigned it to a list variable not a dictionary variable, not ideal but robot framework / python can handle this and convert the list into a dictionary

next i’'ll reformat your data

```python
{
    "name": "RobotTestUser",
    "firstname": "Rob",
    "lastname": "Mc Robot",
    "email": "mcrobot@email.de",
    "roleid": 0
} 400

```

As you can see you placed the 400 after the } outside the dictionary of key/value pairs, this is why I’m not sure how you were expecting the 400 to appear.

Also that JSON style dictionary data format is not mentioned in the documentation for Create Dictionary, so I’m not sure if its supported.

If you were expecting the 400 as a value what should it’s key be? “roleid”?

If you were expecting the 400 as a key what should it’s value be? NULL?

Hopefully one of these will give you what you were wanting:

```python
	&{jsonlines1}= Create Dictionary name RobotTestUser firstname Rob lastname Mc Robot email mcrobot@email.de roleid 0 400 ${EMPTY}

	&{jsonlines1}= Create Dictionary name=RobotTestUser firstname=Rob lastname=Mc Robot email=mcrobot@email.de roleid=0 400=${EMPTY}

	&{jsonlines1}= Create Dictionary name RobotTestUser firstname Rob lastname Mc Robot email mcrobot@email.de roleid 0 newkey 400

	&{jsonlines1}= Create Dictionary name=RobotTestUser firstname=Rob lastname=Mc Robot email=mcrobot@email.de roleid=0 newkey=400

```

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/e/e1fc288e8d88a7d41db33c3ca1e975b7ba69d907.png)

Dave.
