prasath_2k
3 years agoOccasional Contributor
How to read a JSON file
Hi experts, I wanted to read and work with JSON files. Is there best ways to read JSON files using TestComplete? I wanted to trigger the script to fetch the JSON file and do curtains operation by...
- 3 years ago
Hi prasath_2k
Since the JSON file is a text file you might want to compare files doing one of the following:
1. Use the Files.Compare method: Files.Compare Method | TestComplete Documentation (smartbear.com)
2. Do a simple line-by-line comparison of the contents. Reading each file using the aqFile.OpenTextFile method: aqFile.OpenTextFile Method | TestComplete Documentation (smartbear.com)
As AlexKaras stated JScript supports JSON, so you could read it into an object, but the comparison of objects can be difficult. Regardless, below is a screenshot, with code, that shows a JSON object created from a GIS Json file. It shows how to access each of the objects properties (i.e., features, geometry, rings, etc.).