How to read data from json file in local
I have a json file in local ( like: D:\FILE\abc.json). Pls help me when using UFT One
- How I can load json file?
- How I can read data from json file ( like some fields: ID, User, Pass..) then get that data to fill to other fields on web app?
Are you using Gui test or API test.
If Gui test you may need to check this https://stackoverflow.com/questions/12153925/decode-encode-json-with-vbscript
for API test, since it's .net based, so it's easy to use Newtonsoft for parsing.
I am using GUI testing.
My case detail. I have a json file (pls see as attached). I need to get data from this file( like some fields: ID, BID,TYPE...) then msgbox them. pls help in this.
I tried other when I search on google.
- I am using library - appJson.qfl ( https://stackoverflow.com/questions/41610139/using-vbscript-to-access-all-values-in-json-data)
- then I try some code on UFT, but I tried to run it. I got nothing
- pls see more as attached.
1) JSON parse to vbscript dictionaries
2) Excel file editor (without msoffice)
3) Automatic code format
4) Batch runner with portable results
Author - Cracking The QTP Interview Book published by TataMcGrawHill
First of all, from you code, the appJson LoadJSON only accept a JSON string. Below is a workable sample.
Set oJson = NewAspJSON
Set result = oJson.data.Item("Result")
Status = result.item("STATUSCODE")