添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

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?

    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"
                  

    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)

    Log In using your UiPath Account to:

    • get help with your automation projects
    • share feedback, report bugs or just drop us any question
    • become an MVP and get access to
       exclusive events
    • save your user preferences like themes and more
    • automatically sign in to other services
    • get in touch with our Forum staff