Excel Config to Json Config

Hi All,
I need to convert my config file from ReFramework into Json File. Can anyone help me how to convert all the sheets (Settings, Constants, Assets) into Json ? and how can that json file be used in reframework?

Thanks in advance!

Here are all the sheets converted to JSON: JSONConfig.json (962 Bytes)

You can use the UiPath.Web.Acitivities Package to deserialize it into a JObject and access the key/value pairs very similarly to that of the Dictionary<Of String, Object> in the ReFramework. You will need to go through the different workflows and change the argument types of the config and alter the calls to the config variable slightly as well.

If I remember correctly you should be able to do Config("Assets")("Asset1").ToString (See attached file for reference) in order to access the value stored within the given key.

I would however suggest modifying your JSON file to your liking. I personally build out a Config with GLOBAL, LOCAL, DEV, STAGE, and PROD and have a companion deserializing task that detects the runtime environment and then only parses the portions of the JSON that apply. So when I run in DEV I will only parse GLOBAL and DEV. LOCAL/DEV/STAGE/PROD should all have the same elements within them, it just helps you prevent any inline configuration coding.

1 Like

Thanks Mike for the reply but can you provide me an example of xaml code. How that config.json file can be used in ReFramework?

Sorry for the late response… But hopefully this should help if you haven’t gotten it sorted out at this point.

You’ll have to rework the Init state of the process and change the Config Object from type Dictionary<String, Object> to type Newtonsoft.Json.Linq.JObject.

The following .xaml has the basics of what you’ll need to do, the config is stored in “…\Data\Config.json” and looks like this:

{
  "env":"",
  "GLOBAL":{
    "OrchestratorQueueName":"XYZQueue",
    "WebAppCredentialAsset":"XYZCredential",

    "Setting1":"XYZ1",
    "Setting2":"XYZ2",
    "Setting3":"XYZ3",
  },
  "LOCAL":{
    "FilePath":"XYZ_Local",
    "DirectoryPath":"DIR_Local",
  },
  "DEV":{
    "FilePath":"XYZ_Dev",
    "DirectoryPath":"DIR_Dev",
  },
  "STAGE":{
    "FilePath":"XYZ_Stage",
    "DirectoryPath":"DIR_Stage",
  },
  "PROD":{
    "FilePath":"XYZ_Prod",
    "DirectoryPath":"DIR_Prod",
  }
}

I’ve left annotations within the workflows that you can view to help you out as well. Patterning off of this, you can then convert the ReFramework to a JSON Config format and then you can save it as a template to use in future projects.

Example Workflow (Not in ReFramework/State Machine Format): JSONConfigExample.zip (7.3 KB)

Apologies for the late bump, but updating with a much more graceful solution, for anyone else who like me comes to this thread and isn’t impressed by the workaround on offer.

No need to change the Dictionary format or make adjustments to everywhere in the rest of your project that uses the Config; no point in reinventing the wheel, just feed the JSON contents into the existing dictionary structure.

I create a text asset in Orchestrator called “Config_{{ProjectName}}” to hold the json file, but you can do whatever works for your process to get your hands on it - a REST call to ServiceNow, retrieving a text file, whatever.

My repurposed InitAllSettings is attched below.

I’ve repurposed the ReFramework’s in_ConfigFile argument to hold the name of the JSON file to retrieve. You can adjust this to point to however you wish to retrieve it.

The JSON string is then deserialized into a JObject, and we use the in_ConfigSheets argument for it’s stock purpose, to define the sections of the JSON we want to retrieve our data from.

Finally, the Assets section is read and any defined Orchestrator assets are read into the dictionary.

The dictionary is passed out via out_Config in the same dictionary of string/object that the stock ReFramework uses, so no further adjustments are needed anywhere else in the project.

You will need the UiPath.WebAPI.Activities dependency to use the Deserialize JSON activity.

JSON Config.zip (8.1 KB)

please see if this helps