Reading/setting values in appsettings.json file
Hi everyone,
I need to read the localization settings from my appsettings.json file on my server and possible update them too as part of my automated testing. Basically, I need to be able check what supported and fallback languages are defined
How do I read from and Update json files in Testcomplete?
The format of the section I require from the appsettings file is
"Localization": {
"SupportedLanguages": [ "en-US", "fr", "zh" ],
"FallbackLanguage": "en-US",
"SupportedResourceFiles": [
"Base",
"ErrorCodes",
"CoreForms",
"Languages",
"ProductTerms",
"MobileClient",
"OtherClient",
"CustomerTerms"
]
}
I am using Javascript for my TestComplete scripting language
Thanks
Thanks for your reply AlexKaras
Just wanted to update to say that I had managed to get something working, similar to your code above, but using JSON.parse
var fileContents = aqFile.ReadWholeTextFile(filePath, aqFile.ctANSI)
var appSettings = JSON.parse(fileContents)
var defaultLanguage = appSettings.MyID.Localization.FallbackLanguage
return defaultLanguageI haven't tried updating the file yet, haven't need to so far...