# Serialize Json activity

**URL:** <https://forum.uipath.com/t/serialize-json-activity/2719>\
**Category:** Activities\
**Tags:** considering, webapi, activities\
**Created:** [March 23, 2017, 4:07pm UTC](https://forum.uipath.com/t/serialize-json-activity/2719 "2017-03-23T16:07:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrei\_Iliuta](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@Andrei\_Iliuta](https://forum.uipath.com/u/Andrei_Iliuta)\
**Post date:** [March 23, 2017, 4:07pm UTC](https://forum.uipath.com/t/serialize-json-activity/2719/1 "2017-03-23T16:07:22Z")

</div>

I think it would be a good idea to have an activity to serialize an object to JSON. (Since we have one for Deserialize)  
It would be very useful for many stuff, but essentially for loading different types of objects in the orchestrator queue.  
For this we can use JSONConvert.SerializeObject() from Newtonsoft.Json namespace

---

<div class="post-metadata">

**Author:** ![badita](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/badita/32/6_2.png) [@badita](https://forum.uipath.com/u/badita)\
**Post date:** [March 30, 2017, 8:16pm UTC](https://forum.uipath.com/t/serialize-json-activity/2719/2 "2017-03-30T20:16:38Z")

</div>

Can’t they just use the code activity now? Nice to have…

---

<div class="post-metadata">

**Author:** ![Andrei\_Iliuta](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@Andrei\_Iliuta](https://forum.uipath.com/u/Andrei_Iliuta)\
**Post date:** [March 31, 2017, 8:11am UTC](https://forum.uipath.com/t/serialize-json-activity/2719/3 "2017-03-31T08:11:56Z")

</div>

Yeah, of course… it’s only a “nice to have”

---

<div class="post-metadata">

**Author:** ![Ben\_Ten](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ben_ten/32/177246_2.png) [@Ben\_Ten](https://forum.uipath.com/u/Ben_Ten)\
**Post date:** [April 23, 2020, 9:38am UTC](https://forum.uipath.com/t/serialize-json-activity/2719/4 "2020-04-23T09:38:36Z")

</div>

I used the JSONConvert.SerializeObject() object to turn a Dictionary with my metadata into JSON format.  
JSONConvert.SerializeObject(metadata)  
Since we now are switching to the new version # 2019.10.1 I cannot use the method anymore. Because when i try to publish i get the following error Method.

The assembly compilation returned the following errors:

- ‘JsonConvert’: static types cannot be used as type arguments

So now i am a bit lost on what to do.

I dont really know what to do now. How do you serialize JSON in the new Version?

---

<div class="post-metadata">

**Author:** ![jeevith](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jeevith/32/288449_2.png) [@jeevith](https://forum.uipath.com/u/jeevith)\
**Post date:** [October 15, 2020, 7:34am UTC](https://forum.uipath.com/t/serialize-json-activity/2719/5 "2020-10-15T07:34:30Z")

</div>

@Ben_Ten did you find out a solution for this? I just got the same error while trying to publish a library to a specified folder.

![Image](https://global.discourse-cdn.com/uipath/original/3X/5/d/5d6e4d5d7c0170e63d514d02077629cc9e0a7410.png)

---

<div class="post-metadata">

**Author:** ![Ben\_Ten](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ben_ten/32/177246_2.png) [@Ben\_Ten](https://forum.uipath.com/u/Ben_Ten)\
**Post date:** [November 2, 2020, 8:55am UTC](https://forum.uipath.com/t/serialize-json-activity/2719/6 "2020-11-02T08:55:16Z")

</div>

Hi,

sorry for the late answer.  
I wrote a Method in Python which I could then use to serialize the variables.

import json  
import os

def saveAsJson(fileExtention, participationIDs, uwy, documentProfile, creationDate, author, …):  
partIDs = participationIDs.split(“,”)   
uwys = uwy.split(“,”)

```
metadataDict = {"contentRepositoryId":"UW_DOCS_DB",
"documentTypeId":"RD8DOCS",
"documentExtension":fileExtention,
"descriptors":{
	"DOCTREATYNR": partIDs,
	...
"INPUTCHANNEL":inputChannel
}
}

with open(os.path.join(filepath, 'metadata.json'), 'w') as json_file:
    json.dump(metadataDict, json_file)

return "Metadata File Created"

```

---

<div class="post-metadata">

**Author:** ![healsko\_ho](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/healsko_ho/32/176684_2.png) [@healsko\_ho](https://forum.uipath.com/u/healsko_ho)\
**Post date:** [November 11, 2021, 7:59am UTC](https://forum.uipath.com/t/serialize-json-activity/2719/7 "2021-11-11T07:59:47Z")

</div>

When I log message to check the data type of JsonConvert.DeserializeObject(myTextItem).GetType, it’s Newtonsoft.Json.Linq.JObject.

When I put JsonConvert.DeserializeObject(myTextItem), I faced the same error as above.  
My solution is to use a CType for it: CType(JsonConvert.DeserializeObject(myTextItem), Newtonsoft.Json.Linq.JObject)

---

<div class="post-metadata">

**Author:** ![andres.quesada](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/andres.quesada/32/379521_2.png) [@andres.quesada](https://forum.uipath.com/u/andres.quesada)\
**Post date:** [June 22, 2022, 2:06pm UTC](https://forum.uipath.com/t/serialize-json-activity/2719/8 "2022-06-22T14:06:33Z")

</div>

Guys, all we gotta do is not have JsonConvert as a variable in our variables pane. Jsonconvert is a static class, and it tries to get instantiated. Everything worked and i was able to use it just without declaring a jsonconvert type variable.

---

<div class="post-metadata">

**Author:** ![Jefh](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jefh/32/324768_2.png) [@Jefh](https://forum.uipath.com/u/Jefh)\
**Post date:** [September 8, 2023, 4:11pm UTC](https://forum.uipath.com/t/serialize-json-activity/2719/9 "2023-09-08T16:11:59Z")

</div>

![image](https://global.discourse-cdn.com/uipath/original/4X/4/5/e/45e7b649a2aa2241aba4cff61274a0ab75a0f9d0.png)  
Just do this and will be work fine.!
