top class,all youtubers are just validating status becz its easy ,no one is teaching how to parse body becz its difficult even they dont know,after searching found this gem
You are the man! I have been struggling with this exact context over 20 hours. Finally some who goes through every step with explanations. Thanks a lot!
@@FunDooTesters very useful info... But I have a json file in below format { "name" : "vijay" "dob" :"1991" "JsonString" : "/n com.api.getid" {_id :123/r/n ; _fc: abc /r/n ; comp [{ _compname : abc] } "no of instance" :1 } I need to update the id value inside the json string to 345 and write the entire contents back to the json file... Can u pls help on this? I tried updating the id value by traversing to json string - >com.api.getid but when writing back to json file other contents like name, DOB and no of instance go missed and only the json string gets updated into file but unfortunately without the escape characters and line feeds.. Pls help on this
If there're two keys of the same name, then it's reading the value of the first key only (tried in my json). So, Can we read the value from the second key also? For e.g. @ 18:36 , if we do not replace "seq" with "fundootest", then can we parse(read) the value of this particular "seq" which is "1" rather than the one which is already available on the top of it having the value "2". thanks!
if i want to print a particular object value how do we do that? for example in complex json string that you took in the end i want value of count of 8911 object
I am getting error as below when I use JSONObject j=new JSONObject(request) .request is a string containing JSON. How to resolve it. please guide. JSONObject(java.util.Map)' in 'org.json.simple.JSONObject' cannot be applied to '(java.lang.String)'
Thanks for the series of Rest Assured, just a suggestion as you can add more video under this series which can cover more topics such as :- Handling with more number of complex JSON :- Executing number of @Test using tesng.xml format and segregation of in terms of sanity, smoke, regression,etc :- Different types of authentication handle :- Handling of cookies :- Handling and validating using JsonPath :- XML file handling :- Handling of sessions :- Cover more real-time scenarios
Hi Nishant... Have a question. If you see the video at 26th min, the line number 32 and 42 have if conditions. But from the first if condition i.e, line 20 we have got the exists value as false....so what is the use of writing if conditions at line 32 and 42?? Please clarify...
Thank you for sharing. This is great! I have a question though, how can I make it to return a list? Making getKey() method to return a list. That would be very helpful.
brother unable to import org.json.JSONObject as it gives error "A JSONObject is an unordered collection of name/value pairs. Its external form is a string wrapped in curly braces with colons between the names and values, and commas between the values and names." something like that
Hi @Fun Doo Testers thanks for your videos its really helffull. But i need one help. I have one jason in which i want to traverse with key and replace its value and return the json with new replace value. Using your code i am getting only the current node json value not full json. Can you make one video on my issue. Thanks
Hello Sir, Good Evening Can you please share me the link where I can get these complex JSONS whatever you have used in this video. It will be very helpful for me while doing the practice.
How to return getkey method in the same class or another class?. I want to store the json values to compare with expected values . I tried with object return but couldn’t..
Really good explanation !! using this approach can we update some parameter values in the nested json at run time? and will it return the complete json body along with new updated values?
Thanks For it. Its really amazing utility. But while using it I have problem. I have dynamic json with multiple nested json object, json arrays and I want to check each key and want to check which key have NULL value as I need to pass the same json to downstream application without null pointer exception. Could you please give your input. Thanks in advanced.
Hi FunDooTesters, Thank you for sharing your valuable knowledge. I have been trying to use the POJO class inorder to generate json body to the Request Payload. But this looks tedious on multi level nested jsons, is there a way or library available, which can consider the json template and populate the data from either a csv file or xls . I tried to check online but couldnt get much info. Ex: consider below as the template, with $variables could directly be replaced { "names":["firstname": "$fname", "lastname":"$lname"], "personal":["Occup":{ "occ1":"$occvalue","occ2":"$occvalue2" }] } csv file has fname,lname,occvalue,occvalue2 etc FunDo,Tester,value2,value3 James,Jim,value4,value5
@Fun Foo Testers -> How can I get two keys at a time from such deep nested json ? For example I want the output to be in below format: [{"id": "someid1", "name": "Test1"}, {"id": "someid2", "name": "Test2"}.....] and so on..
Thanks for this code really great, how can we return the values of keys, because of recursion return is not properly working, can you please help to add return type to getKey method.
I was waiting this question. Loved it. You have to create static method outside of the getKeys methods. Store all the values and then use it. By the way ill soon upload video for the same.
HI Nishanth , I followed your lecture , i was able to read the json . Can you please help , if i get values for a particular key for example same key 5-6 values .I want to store values in ArrayList Please help
Hi sandeep, Thanks for watching video. To store values in a Array List you can create this method as a return type ArrayList and whatever you are getting as a parse result, those data you can add to arraylist. Thanks
Hi Nishant, Thanks for this utility, Your videos are very helpfull to get the knowledge of java as well as rest assured. Just wanted to one concept here. As once of the json format had array with two objects where the name was choc cake and Ice cake so it was capturing both the values, here i need to capture the only one name as "choc cake" so how i can capture that value by using this utility. Thanks again for helping the testing community.
Hi Anup, Thanks for watching video session. I understand your concern, have small doubt. On what basis are you capturing choc or ice cake? Are you referring from somewhere?
Hi sir am new to API testing. Recently in one interview I was asked how do you validate get response ( dynamic response). Example send get request to find out number of Samsung phone in Portal but the result will change dynamically every time. How do you validate the result. Please help me with this query
This video is the best answer for your question. Please watch and try it with different types of json data. Feel free to reach me if you have further queries
During the post method, I'm getting json value could not be converted to System.String... cam you please confirm what is the issue here! Tried all the method not worked..
Hi Praveen, could you please share code on fundootesters@gmail.com. I’ll take a look and before that you can go through github.com/Fundootesters/RestAssuredFramework and make sure you have written same logic and used same libs
@@FunDooTesters { "arrayKey" : ["firstElement", "secondElement", "thirdElement"] } as { "arrayKey" : ["secondElement", "firstElement1", "thirdElement"] } i want to match the expected and actual API response but in the Actual reponse the array is dynamic every time i fetch the response.
@@vinamungekar Key should be static. Get the array object, Sort it, Compare using comparator or something similar. Like - Comparing Object References - Comparing Array Lengths - Arrays.equals method - Arrays.deepEquals method
I have a scenario where i want parse the jsonobject and if id matches (i.e 123) i need to replace the name (ggg) . Input : [{"id":123","name"abc"},{"id"456":"xyz"}] and the output i'm expecting is [{"id":123","name"ggg"},{"id"456":"xyz"}] . I dont want to use to string replace . I need to parse and update the value.
Consider your json as a array. You need to iterate over json. Each element will give you json object. Just check Getting desire id values or not. Org.json lib will help you here
Thanks Nishant @Fun Doo Testers for the amazing solution; it helped me a lot. But I'm having one query here. Until parsing the json, this logic is fine, but after finding it if we want to update the value of that same property and want to get the whole json returned with the updated value as a string, how can I make it possible using this code?
Hi Bro.. excellent tutorial for reading the complex json reponse... need your help... could you please let me know how do we update the json file which nested like the one in complex example jsoninput
I want to return a list of values returned from this method to be used in another method but because of recursive call it sets the list to null. Please suggest some way to resolve my problem. I will be very thankful to you
Instead of printing I want to Store that value in a object and return it. In another class I will call getKey() method and Store that value. How to do that? You have taken void as return type. I can not get the value in another class.
Thank you liked it. Please consider subscribing channel and share with friends too. I will be appreciated. Here is a github repo: github.com/Fundootesters/RestAssuredFramework
@@FunDooTesters one thing here which is failing for me, in JASONArray loop it is failing it is trying to convert a single value to JsonObject. Can u plz help me on this.
Hi Nishant, Is this the only way to parse a JSON and do assertion? I see some videos where they have done using JsonPath, which is easier as well. When should we go with JSONObject and JSONArray approach in real-time projects?
Hi Aditya, In that case we need to write jsonpath for different response as well as different key and it won't work for dynamic and nested json. Even you can watch this as well th-cam.com/video/xvg74eXR66I/w-d-xo.html Need to figure out based on scenarios
Great explanation, thank you. but i have a problem. I need to read dynamically a swagger definition (complex json file) Then I will assign values retrieved from the JSONfile to ATTRIBUTES OF XML elements. I have to retrieve data and keep dependencies between objects. For example, I have to know all operationId and for each operation want to keep its information (responses, path, get or post..) and it referred to which tag. THE JSON FORMAT IS AS BELOW "paths": { "/api/v1/users": { "get": { "tags": [ "user-controller" ], "operationId": "getAllUsers", "responses": { "200": {} "post": { "tags": [ "user-controller" ], "operationId": "getAllUsers", "responses": { "200": {} "/api/v1/post": { "get": { "tags": [ "user-controller" ], "operationId": "getAllUsers", "responses": { "200": {} PLEASE WHAT CAN I DO ? thanks in advance
Hi Mariem, I understood problem statement. You will get solutions from google “extract data from swagger json”. Basically you need to understand mapping of data. You will find inbuilt methods to extract data. This is bit different thn json parsing We are also planning to cover such topics but it takes time. You can write me again if you have any doubts. Thanks, Nishant
Common parsing utility need to develop once and can be used everywhere Json path every time need to write whenever have to extract data. Both works well. Can be chosen based on requirements
Hi can anyone let me know , while passing the json as string in java code, do you have to manually put all the backwards slashes before " or is there any way to do it automatically. Thanks!
Hi Sir, Thanks for the video. Its really helpful. I have one scenario where I have multiple keys with same name within same json object and I want don't want to get all the values but only those value which is having specific parent. Can you please help me with this?
Nice question! You mean to say inside JSON array you have multiple JSON objects with same data or how ; multiple duplicate keys are not possible. It would be great if you can share sample JSON fundootesters@gmail.com
@@FunDooTesters Json file looks like this : { "matchingProfileName" : "CDQA-1", "ProfileType": "CD-Type-1" } { "matchingProfileName" : "CDQA-2", "ProfileType": "CFD-Type-2" } { "matchingProfileName" : "CFDQA-3", "ProfileType": "CFD-Type-23 } I need to validate all 'matchingProfileName's.How can I validate all matching profiel names
Hi Nishant, Thx for this lecture . Can you explain how to remove all attributes from the JsonObject if that contains as some specific value or empty or null value present ?
Hi Ajaiya Pandey, thanks for watching the video. In this case first you have to validate null/specific values using iterating entire json. and then you can remove that attributes. .remove() method is available for the same.
Hatsoff man 👍Really cool stuff which I was looking for .
Thanks a lot for your effort🙏
Glad to hear that
How to remove jsonArray from JsonObject?
top class,all youtubers are just validating status becz its easy ,no one is teaching how to parse body becz its difficult even they dont know,after searching found this gem
Glad to hear that. Stay tuned with us for amazing content
You are the man! I have been struggling with this exact context over 20 hours. Finally some who goes through every step with explanations. Thanks a lot!
Wonderful
@@FunDooTesters very useful info... But I have a json file in below format
{
"name" : "vijay"
"dob" :"1991"
"JsonString" : "/n com.api.getid" {_id :123/r/n ; _fc: abc /r/n ; comp [{ _compname : abc] }
"no of instance" :1
}
I need to update the id value inside the json string to 345 and write the entire contents back to the json file... Can u pls help on this? I tried updating the id value by traversing to json string - >com.api.getid but when writing back to json file other contents like name, DOB and no of instance go missed and only the json string gets updated into file but unfortunately without the escape characters and line feeds.. Pls help on this
One of the best tutorials ever found on internet on api...really appreciate your efforts.
Glad you liked it. Such comments give strength to create more videos 🙏
OMG......I browsed for days for this content but no luck until i get this.No one has provided this so far.. you are awesome Sir....
Glad you liked it 👍🏻
Stay tuned with fun foo testers for more fun and learning
very nice logic. It really reduced the POJO classes and its logic . Thanks a lot.
Thank u so much I used to never understand json thing bt this video helped me a lot!!!
I have been searching for this since longtime. Finally got it. Thanks a lot and a very nice and clean explanation too.
Glad it helped
Great, really appriciated for all your efforts...One of the best trainer🤘 keep posting more n more
Great work Nishant! Expecting more Java videos like this scenario from you! thanks :)
Glad you liked it. I’m planning for new series on java after completing current on software testing. Stay tuned with fun doo testers
@@FunDooTesters Hi Sir can i have one video where we compare two API Json Response and print the difference between them if any. Thanks in advance
If there're two keys of the same name, then it's reading the value of the first key only (tried in my json). So, Can we read the value from the second key also? For e.g. @ 18:36 , if we do not replace "seq" with "fundootest", then can we parse(read) the value of this particular "seq" which is "1" rather than the one which is already available on the top of it having the value "2".
thanks!
this video is very helpful. thanks bhaiya!!!!
Thank you 🙏
Really good. I was looking for this. Thank you sir
Great explanation, thank you. If you are a developer working with JSON then DeltaJSON is really useful, it has an API for compare, merge and graft.
Glad you like the explanation. I’ll take a look of daltajson. Thanks for the suggestions
if i want to print a particular object value how do we do that? for example in complex json string that you took in the end i want value of count of 8911 object
Excellent...I was looking for this stuff for long time 👍👍
Glad you liked it. Stay tuned for upcoming courses
I am getting error as below when I use JSONObject j=new JSONObject(request) .request is a string containing JSON. How to resolve it. please guide.
JSONObject(java.util.Map)' in 'org.json.simple.JSONObject' cannot be applied to '(java.lang.String)'
Thanks for the series of Rest Assured, just a suggestion as you can add more video under this series which can cover more topics such as
:- Handling with more number of complex JSON
:- Executing number of @Test using tesng.xml format and segregation of in terms of sanity, smoke, regression,etc
:- Different types of authentication handle
:- Handling of cookies
:- Handling and validating using JsonPath
:- XML file handling
:- Handling of sessions
:- Cover more real-time scenarios
Glad you liked it. Sure Suryakant I’ll try to cover these topics after ongoing series
Great stuff!!!! Thanks for sharing 😀
Thanks a lot for Sharing , great examples and code
Which dependency u have used for jsonobject at 3:29 I am using json simple vala but it is throwing me error
Hi Komal,
Here is a pom.XML github.com/Fundootesters/RestAssuredFramework/blob/master/pom.xml
I hope it will help you
Really great implementation
Hi Nishant...
Have a question.
If you see the video at 26th min, the line number 32 and 42 have if conditions.
But from the first if condition i.e, line 20 we have got the exists value as false....so what is the use of writing if conditions at line 32 and 42??
Please clarify...
Yes you can remove inside if condition
@@FunDooTesters thanks for a very quick response... glad I found this channel.
.much love.
Excellent stuff man!!! hats off!!! you just made life simple...
Thanks for sharing your knowledge. Much appreciated :)
Awesome stuff
Thank you so much for sharing the informative content!!
Glad it was helpful!
Thank you so much for sharing your knowledge with us!
God bless you!
Glad you liked it. You are so kind
Thank you for sharing. This is great! I have a question though, how can I make it to return a list? Making getKey() method to return a list. That would be very helpful.
Do we need 'if' condition 'exists==False' on line 32 and 42. It is already verified on line 26. Please comment on need for additional condition....
Is it possible to exclude the method from parsing certain arrays?
brother unable to import org.json.JSONObject as it gives error "A JSONObject is an unordered collection of name/value pairs. Its external form is a string wrapped in curly braces with colons between the names and values, and commas between the values and names." something like that
Please add correct dependency mvnrepository.com/artifact/org.json/json/20200518
Hi @Fun Doo Testers thanks for your videos its really helffull. But i need one help. I have one jason in which i want to traverse with key and replace its value and return the json with new replace value. Using your code i am getting only the current node json value not full json. Can you make one video on my issue. Thanks
Hello Sir, Good Evening
Can you please share me the link where I can get these complex JSONS whatever you have used in this video. It will be very helpful for me while doing the practice.
How to return getkey method in the same class or another class?. I want to store the json values to compare with expected values . I tried with object return but couldn’t..
Store data in pojo share use shared object, that should solve purpose
Please help us to know how we can achieve it
I have one doubt regarding this. I have linked hashmap instead of hash map in my json, but iam not able to do the keys operation on the object.Why?
Hi Gijo,
Not able to understand, Could you please elaborate . Apology for late reply.
Thanks a lot, man! Great job, it helps me a lot.
Glad to hear that!
Good one bro
Really good explanation !! using this approach can we update some parameter values in the nested json at run time? and will it return the complete json body along with new updated values?
Glad you liked it. I guess no. Let me find a solution. Will revert shortly.
-Nishant
I was looking this. Thank you sir
I am not able to get some of the static methods that you are using when I used the simple JSON from Google
Checkout pom github.com/Fundootesters/RestAssuredFramework/blob/master/pom.xml
Thanks For it. Its really amazing utility. But while using it I have problem.
I have dynamic json with multiple nested json object, json arrays and I want to check each key and want to check which key have NULL value as I need to pass the same json to downstream application without null pointer exception. Could you please give your input. Thanks in advanced.
May I ask how this can be used to update an element and return back the original JSON with the updated element? thank you very much!
Use jsonpath
Hi FunDooTesters,
Thank you for sharing your valuable knowledge.
I have been trying to use the POJO class inorder to generate json body to the Request Payload.
But this looks tedious on multi level nested jsons, is there a way or library available, which can consider the json template and populate the data from either a csv file or xls . I tried to check online but couldnt get much info.
Ex: consider below as the template, with $variables could directly be replaced
{
"names":["firstname": "$fname", "lastname":"$lname"],
"personal":["Occup":{ "occ1":"$occvalue","occ2":"$occvalue2" }]
}
csv file has
fname,lname,occvalue,occvalue2 etc
FunDo,Tester,value2,value3
James,Jim,value4,value5
What do you have as an input, JSON schema?
@Fun Foo Testers -> How can I get two keys at a time from such deep nested json ? For example I want the output to be in below format: [{"id": "someid1", "name": "Test1"}, {"id": "someid2", "name": "Test2"}.....] and so on..
Thanks for this code really great, how can we return the values of keys, because of recursion return is not properly working, can you please help to add return type to getKey method.
I was waiting this question. Loved it.
You have to create static method outside of the getKeys methods. Store all the values and then use it. By the way ill soon upload video for the same.
Waiting for the same bro..
Hi,
When will you upload the video ..Please help us
@@FunDooTesters Hi, may I know if you have the solution for this? Thank you.
@@FunDooTesters Did you upload video for the same?
Can we use blob and clob objects in the json response as well, will it work with that as well?
So you mean to say value as a blob? Or how it will be? If in key value pair value will be blog then finally it will be string. In this it will work
@@FunDooTesters thanks for responding quickly, can you please provide suggestions how can I mask and unmask the dynamically generated json data.
You can do with gson or regix pattern
HI Nishanth ,
I followed your lecture , i was able to read the json . Can you please help , if i get values for a particular key for example same key 5-6 values .I want to store values in ArrayList Please help
Hi sandeep,
Thanks for watching video. To store values in a Array List you can create this method as a return type ArrayList and whatever you are getting as a parse result, those data you can add to arraylist.
Thanks
Hi Nishant, Thanks for this utility, Your videos are very helpfull to get the knowledge of java as well as rest assured.
Just wanted to one concept here. As once of the json format had array with two objects where the name was choc cake and Ice cake so it was capturing both the values, here i need to capture the only one name as "choc cake" so how i can capture that value by using this utility.
Thanks again for helping the testing community.
Hi Anup,
Thanks for watching video session.
I understand your concern, have small doubt. On what basis are you capturing choc or ice cake? Are you referring from somewhere?
Hello, how are you converting a json input into string value in eclipse?
It will automatically considered as string if you declare as string.
Hi sir am new to API testing. Recently in one interview I was asked how do you validate get response ( dynamic response). Example send get request to find out number of Samsung phone in Portal but the result will change dynamically every time. How do you validate the result. Please help me with this query
This video is the best answer for your question. Please watch and try it with different types of json data. Feel free to reach me if you have further queries
During the post method, I'm getting json value could not be converted to System.String... cam you please confirm what is the issue here! Tried all the method not worked..
Hi Praveen, could you please share code on fundootesters@gmail.com. I’ll take a look and before that you can go through github.com/Fundootesters/RestAssuredFramework and make sure you have written same logic and used same libs
How to get Unique values , like i need id at 2nd place only as String not all values of key id
Jsonpath will solve your problem easily
Hey Thank you for your wonderful explanation , Could you please share dependency you have used with version ?
Hey Yogesh, glad you liked it.
github.com/Fundootesters/RestAssuredFramework
How do i compare the JSON objects in my array where the expected objects are not changing but the actual oder of response of objects is changing.
Not able to understand your problem statement completely. Try sorting and comparator. It should work
@@FunDooTesters {
"arrayKey" : ["firstElement", "secondElement", "thirdElement"]
}
as
{
"arrayKey" : ["secondElement", "firstElement1", "thirdElement"]
} i want to match the expected and actual API response but in the Actual reponse the array is dynamic every time i fetch the response.
@@vinamungekar Key should be static. Get the array object, Sort it, Compare using comparator or something similar. Like
- Comparing Object References
- Comparing Array Lengths
- Arrays.equals method
- Arrays.deepEquals method
@@NishantGohel is your mail id available...i can explain it to you better
Thank you so much!
Thanks mate! Very helpful
Glad it helped!
What should we do if the object inside of the JSONArray is not having a key to it, how do we fetch it?
what is the dependency you are using in your POM ?
Take a look github.com/Fundootesters/RestAssuredFramework/blob/master/pom.xml
thanks, sir @Fun Doo Testers
Json string to java object conversion. But my java object has map in it along with other variables.
Map
In that case how we can achieve it.
Key= employee object I’d
Value= employe object.
If you can share complete data I can help
I have a scenario where i want parse the jsonobject and if id matches (i.e 123) i need to replace the name (ggg) . Input : [{"id":123","name"abc"},{"id"456":"xyz"}] and the output i'm expecting is [{"id":123","name"ggg"},{"id"456":"xyz"}] . I dont want to use to string replace . I need to parse and update the value.
Consider your json as a array. You need to iterate over json. Each element will give you json object. Just check Getting desire id values or not. Org.json lib will help you here
Hi Fundoo will u pls help with my JSON as it is little different from yours and parsing root is also different
Please share take a look github.com/Fundootesters/RestAssuredFramework/blob/master/src/main/java/utils/ParseDynamicJson.java once
Which Json library are you using is it open-source??
Yes it is free org.Json please have a look below github.com/Fundootesters/RestAssuredFramework/blob/master/pom.xml
Really Good!! Keep it up :)
Thank you
Really help method.
Please tell me how to create dynamic function to update the jaon value in json file..thank you in advance...
What's the reference of dynamic JSON, you can create a pojo of entire schema, after you can serialised or de serlialise data based on your need.
Thanks Nishant @Fun Doo Testers for the amazing solution; it helped me a lot. But I'm having one query here. Until parsing the json, this logic is fine, but after finding it if we want to update the value of that same property and want to get the whole json returned with the updated value as a string, how can I make it possible using this code?
You can write store values in desire collection like list or hasmap even pojo will work
Hi Bro.. excellent tutorial for reading the complex json reponse... need your help... could you please let me know how do we update the json file which nested like the one in complex example jsoninput
Sure will add soon stay tuned
It's 4 in the morning just want to thank you, can I buy you a cup of coffee?
You are too kind. Glad you liked it
please provide these nested json files you have used. it will help me while learning on my eclipse IDE.
Why don't you use Hashmap instead? esp for the dynamic json objects
Hashmap also we can use
Can you make a video on updating the value for dynamic json?
I want to return a list of values returned from this method to be used in another method but because of recursive call it sets the list to null. Please suggest some way to resolve my problem. I will be very thankful to you
Did you get a solution for this problem? If you did please share. How to get getKey() method to return list. Thank you,
bro i am using this code but getting lots of error, JSONObject.has(); json.keys(); etc having error ,,,plz suggest proper library
Instead of printing I want to Store that value in a object and return it. In another class I will call getKey() method and Store that value. How to do that? You have taken void as return type. I can not get the value in another class.
You can create a static list and get all the data.
Note: this method has more complexity in terms of framework coz of recurs ion
This is one of the best video I have seen, excellent explanations. Could I get the git repo url for this.?
Thank you liked it. Please consider subscribing channel and share with friends too. I will be appreciated.
Here is a github repo: github.com/Fundootesters/RestAssuredFramework
@@FunDooTesters Thank you, sure I will do that.
@@FunDooTesters one thing here which is failing for me, in JASONArray loop it is failing it is trying to convert a single value to JsonObject. Can u plz help me on this.
Did not get you. COuld you please share more details?
Very good.
Hi Nishant, Is this the only way to parse a JSON and do assertion? I see some videos where they have done using JsonPath, which is easier as well. When should we go with JSONObject and JSONArray approach in real-time projects?
Hi Aditya,
In that case we need to write jsonpath for different response as well as different key and it won't work for dynamic and nested json.
Even you can watch this as well th-cam.com/video/xvg74eXR66I/w-d-xo.html
Need to figure out based on scenarios
@@FunDooTesters Thanks Nishant.Can you please upload the code on github.
Great explanation, thank you. but i have a problem.
I need to read dynamically a swagger definition (complex json file)
Then I will assign values retrieved from the JSONfile to ATTRIBUTES OF XML elements.
I have to retrieve data and keep dependencies between objects.
For example, I have to know all operationId and for each operation want to keep its information (responses, path, get or post..) and it referred to which tag.
THE JSON FORMAT IS AS BELOW
"paths": {
"/api/v1/users": {
"get": {
"tags": [
"user-controller"
],
"operationId": "getAllUsers",
"responses": {
"200": {}
"post": {
"tags": [
"user-controller"
],
"operationId": "getAllUsers",
"responses": {
"200": {}
"/api/v1/post": {
"get": {
"tags": [
"user-controller"
],
"operationId": "getAllUsers",
"responses": {
"200": {}
PLEASE WHAT CAN I DO ? thanks in advance
Hi Mariem,
I understood problem statement. You will get solutions from google “extract data from swagger json”. Basically you need to understand mapping of data. You will find inbuilt methods to extract data. This is bit different thn json parsing
We are also planning to cover such topics but it takes time. You can write me again if you have any doubts.
Thanks,
Nishant
what is it's advantage over jsonpath ?
Common parsing utility need to develop once and can be used everywhere
Json path every time need to write whenever have to extract data.
Both works well. Can be chosen based on requirements
can i put file in place of pasting the string in json
Yes you can
Hi can anyone let me know , while passing the json as string in java code, do you have to manually put all the backwards slashes before " or is there any way to do it automatically. Thanks!
It will automatically come when you paste json as a string in your IDE.
@@FunDooTesters thanks! You are doing a great job, keep it up👏
Good video
Hi Sir,
Thanks for the video. Its really helpful.
I have one scenario where I have multiple keys with same name within same json object and I want don't want to get all the values but only those value which is having specific parent. Can you please help me with this?
Nice question! You mean to say inside JSON array you have multiple JSON objects with same data or how ; multiple duplicate keys are not possible. It would be great if you can share sample JSON fundootesters@gmail.com
@@FunDooTesters
Json file looks like this :
{ "matchingProfileName" : "CDQA-1",
"ProfileType": "CD-Type-1"
}
{ "matchingProfileName" : "CDQA-2",
"ProfileType": "CFD-Type-2"
}
{ "matchingProfileName" : "CFDQA-3",
"ProfileType": "CFD-Type-23
}
I need to validate all 'matchingProfileName's.How can I validate all matching profiel names
Were you able to resolve this scenario?
in code i got error like json cannot be resolved what should i do?
Can you please share more details?
Thank u for the code, can u pls explain how to pass multi form data with complex json objects to rest api.. Thanks
Loop through list/map to pass data.
How to exit from this program when we have got the required value for the key?
It will automatically exit. No need to worry
Also can you please make video on how to parse json to java bean for dynamic json
Sure
Sooper cool... But it is more better if you can adjust the subtitle... It will improves the readability..
Sure i will update
How can we get the values for all the keys instead of just one key?
You can flatten the response and loop through. It will give you all values and keys.
@@FunDooTesters can you suggest the method to do it?
Great Tutorial!. Can you create video on how to update any field in JSON on the fly?
Yes I will
How to remove specific elements from simple.jsonObject? Remove not working
Json.remove()
If it is related to specific object like If I want phone number of particular student then what will be the way
You have to search student name first thn within that object or list go for phone number. Think like nested array
Hi Nishant, Thx for this lecture . Can you explain how to remove all attributes from the JsonObject if that contains as some specific value or empty or null value present ?
Hi Ajaiya Pandey,
thanks for watching the video. In this case first you have to validate null/specific values using iterating entire json. and then you can remove that attributes. .remove() method is available for the same.
I cannot use JSONObject class. What to do?
Have you correctly imported?
@@FunDooTesters seems I imported nothing. I'll check once again.
Thank you
Hi , can i get some solution without recursion?
Don’t think so it is possible for any json
Nice Tutorial can you make video on java object to json using GSON for nested object and array with some complexity
Will upload soon
Can you please share the json data and code details in the description
github.com/Fundootesters/RestAssuredFramework/blob/master/src/main/java/utils/ParseDynamicJson.java