Big news! The community will be moving to a new platform April 21. Read more.
Big news! The community will be moving to a new platform April 21. Read more.
Vice Admiral
Vice Admiral
513 views

How to read data from json file in local

Hi expert,

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?

Thanks,

QuyenTA

 

 

0 Likes
7 Replies
Vice Admiral
Vice Admiral

pls help in this case.

0 Likes
Micro Focus Expert
Micro Focus Expert

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.

0 Likes
Vice Admiral
Vice Admiral

Hi Jerrry,

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.

Thanks,

 

0 Likes
Commander Commander
Commander

It's high time. UFT should provide support for few technologies.
1) JSON parse to vbscript dictionaries
2) Excel file editor (without msoffice)
3) Automatic code format
4) Batch runner with portable results

Thanks,
Sudhakar Kakunuri
www.QtpSudhakar.com
Author - Cracking The QTP Interview Book published by TataMcGrawHill
0 Likes
Vice Admiral
Vice Admiral

Hi Sudhakar Kakunuri,

Yes, I hope so...

0 Likes
Captain Captain
Captain

Hi, 

we are using this API https://www.chilkatsoft.com/refdoc/xChilkatJsonObjectRef.html

It's free and working well for reading  writing json files (complex and simple ones)

Cheers

mti

 

0 Likes
Micro Focus Expert
Micro Focus Expert

First of all, from you code, the appJson LoadJSON only accept a JSON string. Below is a workable sample.

Set oJson = NewAspJSON
oJson.loadJSON("{Result:{STATUSCODE:'000000',DATA:{ID:19,BID:'123',TYPE:'432432'}}}")

Set result = oJson.data.Item("Result")
Status = result.item("STATUSCODE")

msgbox Status

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.