How to parse dynamic and nested JSON in java? - Rest assured API automation framework

Sdílet
Vložit
  • čas přidán 2. 04. 2020
  • Rest Assured is very popular in API Test Automation. REST Assured API can be used to invoke REST web services and match response content to test them. This video is about how we can parse JSON data to Java Object where keys are dynamically created.
    ✅ In this Rest-Assured video, we will be learning,
    1. How to parse dynamic JSON?
    2. How to parse nested JSON?
    3. How to write a recursive Code?
    4. Code debugging.
    🔥🔥🔥 In Hindi: • How to parse dynamic a...
    🔥🔥🔥 One to One connect with Fun Doo Testers : topmate.io/fundootesters
    ✅ If you like my videos, please consider buying me a coffee: www.buymeacoffee.com/fundoote...
    Good books to read :
    ✅ Head First Java: amzn.to/2ZQlXqI
    ✅ Cracking Coding interviews: amzn.to/3bDX8Un
    ✅ For business write us on: Contact@fundootesters.com
    ✅ Say hello to us, and stay updated!
    Facebook: / fundootesters
    Instagram: / fundootesters
    LinkedIn: / fundootesters
    Blog: / fundootesters #Restassured #API #fundootesters
    GitHub: github.com/Fundootesters/Rest...
    GEAR USE:
    ○ My Camera: amzn.to/3e2UqL7
    ○ Microphone: amzn.to/3bSUvOq
    ○ Microphone:amzn.to/2ZXuo3s
    ○ Tripod: amzn.to/2PqmTQN
    DISCLAIMER
    Links included in this description might be affiliate links. If you purchase a product or service with the links that I provide I may receive a small commission. There is no additional charge to you! Thank you for supporting me so I can continue to provide you with free content each week!
    #Json #RestAssured #FunDooTesters

Komentáře • 255

  • @naveenbv1838
    @naveenbv1838 Před 4 lety +17

    Hatsoff man 👍Really cool stuff which I was looking for .
    Thanks a lot for your effort🙏

  • @ensarbati5271
    @ensarbati5271 Před rokem +2

    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
      @FunDooTesters  Před rokem +1

      Wonderful

    • @vijayendranvijay4538
      @vijayendranvijay4538 Před rokem

      ​​@@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

  • @manishpatidar5379
    @manishpatidar5379 Před 3 lety +3

    One of the best tutorials ever found on internet on api...really appreciate your efforts.

    • @FunDooTesters
      @FunDooTesters  Před 3 lety

      Glad you liked it. Such comments give strength to create more videos 🙏

  • @udemytesters
    @udemytesters Před 3 lety

    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....

    • @FunDooTesters
      @FunDooTesters  Před 3 lety

      Glad you liked it 👍🏻
      Stay tuned with fun foo testers for more fun and learning

  • @mfs1316
    @mfs1316 Před 2 lety

    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

    • @FunDooTesters
      @FunDooTesters  Před 2 lety

      Glad to hear that. Stay tuned with us for amazing content

  • @ganeshmynampati1607
    @ganeshmynampati1607 Před rokem

    I have been searching for this since longtime. Finally got it. Thanks a lot and a very nice and clean explanation too.

  • @testqaa1626
    @testqaa1626 Před 3 lety +2

    Really good. I was looking for this. Thank you sir

  • @samirangelgmit
    @samirangelgmit Před 3 lety +2

    Great, really appriciated for all your efforts...One of the best trainer🤘 keep posting more n more

  • @rameshgaming1020
    @rameshgaming1020 Před 3 lety

    Excellent stuff man!!! hats off!!! you just made life simple...

  • @sridharraju3249
    @sridharraju3249 Před 2 lety +2

    Great work Nishant! Expecting more Java videos like this scenario from you! thanks :)

    • @FunDooTesters
      @FunDooTesters  Před 2 lety +2

      Glad you liked it. I’m planning for new series on java after completing current on software testing. Stay tuned with fun doo testers

    • @sumiranraut8845
      @sumiranraut8845 Před 2 lety

      @@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

  • @shwetaoberoi6044
    @shwetaoberoi6044 Před 2 lety

    very nice logic. It really reduced the POJO classes and its logic . Thanks a lot.

  • @monalishapradhan1495
    @monalishapradhan1495 Před 2 lety

    Great stuff!!!! Thanks for sharing 😀

  • @yoshitamahajan353
    @yoshitamahajan353 Před rokem

    Thank u so much I used to never understand json thing bt this video helped me a lot!!!

  • @delarcro
    @delarcro Před 3 lety +1

    Really great implementation

  • @abhisheks2505
    @abhisheks2505 Před 2 lety

    Thanks for sharing your knowledge. Much appreciated :)

  • @aniltamhane5499
    @aniltamhane5499 Před 3 lety

    Excellent...I was looking for this stuff for long time 👍👍

    • @FunDooTesters
      @FunDooTesters  Před 3 lety

      Glad you liked it. Stay tuned for upcoming courses

  • @me.nilesh
    @me.nilesh Před 4 lety

    Thanks mate! Very helpful

  • @markthomas9641
    @markthomas9641 Před 2 lety +1

    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.

    • @FunDooTesters
      @FunDooTesters  Před 2 lety

      Glad you like the explanation. I’ll take a look of daltajson. Thanks for the suggestions

  • @testsaucelabs6997
    @testsaucelabs6997 Před 3 lety

    I was looking this. Thank you sir

  • @ggmushorts
    @ggmushorts Před 2 lety +2

    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

    • @FunDooTesters
      @FunDooTesters  Před 2 lety +1

      Glad you liked it. Sure Suryakant I’ll try to cover these topics after ongoing series

  • @julissamendezangeles
    @julissamendezangeles Před 2 lety

    Thanks a lot for Sharing , great examples and code

  • @tanunesta
    @tanunesta Před 2 lety

    Thank you so much for sharing your knowledge with us!
    God bless you!

  • @anupkapale7953
    @anupkapale7953 Před 4 lety +2

    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.

    • @FunDooTesters
      @FunDooTesters  Před 4 lety +1

      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?

  • @SoltLikeThis
    @SoltLikeThis Před 2 lety

    Thanks a lot, man! Great job, it helps me a lot.

  • @sakshiaggarwal6199
    @sakshiaggarwal6199 Před 2 lety

    Thank you so much for sharing the informative content!!

  • @jayantagarwal6339
    @jayantagarwal6339 Před 3 lety +1

    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!

  • @suhailakhtar1707
    @suhailakhtar1707 Před rokem

    this video is very helpful. thanks bhaiya!!!!

  • @shubhamsharma-mt4hs
    @shubhamsharma-mt4hs Před 3 lety +1

    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

  • @nguyenquan4836
    @nguyenquan4836 Před rokem

    Thank you so much!

  • @jayantagarwal6339
    @jayantagarwal6339 Před 3 lety

    thanks, sir @Fun Doo Testers

  • @bapusoumya1
    @bapusoumya1 Před 3 lety

    Really Good!! Keep it up :)

  • @flight_of_phoenix
    @flight_of_phoenix Před 3 lety +1

    Awesome stuff

  • @vaishalichavhan4536
    @vaishalichavhan4536 Před 2 lety +1

    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)'

  • @rakeshs277
    @rakeshs277 Před 3 lety

    Really help method.

  • @rajesho9772
    @rajesho9772 Před 3 lety

    Good one bro

  • @keepsmile564
    @keepsmile564 Před 3 lety

    Very good.

  • @mangesh89
    @mangesh89 Před rokem

    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.

  • @durveshbhole9
    @durveshbhole9 Před 3 lety

    @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..

  • @pradhyumnakandamuru
    @pradhyumnakandamuru Před 3 lety

    What should we do if the object inside of the JSONArray is not having a key to it, how do we fetch it?

  • @anuvarshini5116
    @anuvarshini5116 Před 4 lety +1

    Hi Thanks for the utility,it was well explained. However can you upload a video of how to pass TestData using Excel - Apache POI API

    • @FunDooTesters
      @FunDooTesters  Před 4 lety +1

      Thanks for watching video. I will upload in sometime. Meanwhile stay tuned with us

  • @pareshmkulkarni
    @pareshmkulkarni Před rokem

    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....

  • @yelloverz5537
    @yelloverz5537 Před 4 lety +1

    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?

    • @FunDooTesters
      @FunDooTesters  Před 4 lety +1

      Hi Gijo,
      Not able to understand, Could you please elaborate . Apology for late reply.

  • @sandeepb6253
    @sandeepb6253 Před 4 lety +1

    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

    • @FunDooTesters
      @FunDooTesters  Před 4 lety +2

      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

  • @dineshkarthik5732
    @dineshkarthik5732 Před 3 lety

    Good video

  • @ArunRajput-ut7gt
    @ArunRajput-ut7gt Před 3 lety +1

    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

    • @FunDooTesters
      @FunDooTesters  Před 3 lety +1

      Please add correct dependency mvnrepository.com/artifact/org.json/json/20200518

  • @haribabuvelakavaram5935
    @haribabuvelakavaram5935 Před 3 lety +1

    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...

    • @FunDooTesters
      @FunDooTesters  Před 3 lety

      Yes you can remove inside if condition

    • @haribabuvelakavaram5935
      @haribabuvelakavaram5935 Před 3 lety

      @@FunDooTesters thanks for a very quick response... glad I found this channel.
      .much love.

  • @amir208501
    @amir208501 Před rokem

    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.

  • @yogeshnipate
    @yogeshnipate Před rokem

    Hey Thank you for your wonderful explanation , Could you please share dependency you have used with version ?

    • @FunDooTesters
      @FunDooTesters  Před rokem +1

      Hey Yogesh, glad you liked it.
      github.com/Fundootesters/RestAssuredFramework

  • @surwase1
    @surwase1 Před 3 lety

    Great Tutorial!. Can you create video on how to update any field in JSON on the fly?

  • @qibbs8934
    @qibbs8934 Před rokem

    Is it possible to exclude the method from parsing certain arrays?

  • @ajaiyapandey5058
    @ajaiyapandey5058 Před 4 lety

    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 ?

    • @FunDooTesters
      @FunDooTesters  Před 4 lety +1

      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.

  • @vinothvijay85
    @vinothvijay85 Před 2 lety

    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.

    • @FunDooTesters
      @FunDooTesters  Před 2 lety

      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

  • @vineetnt
    @vineetnt Před rokem

    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?

    • @FunDooTesters
      @FunDooTesters  Před rokem

      Glad you liked it. I guess no. Let me find a solution. Will revert shortly.
      -Nishant

  • @bathulanagendra4621
    @bathulanagendra4621 Před 4 lety +1

    Hi sir, Video was very much informative,and solving real world scenarios in JSON Formatting. If possible please share source code ,it will be much helpful.

    • @FunDooTesters
      @FunDooTesters  Před 4 lety +1

      Hi Bathula Nagendra,
      Glad you liked it. Please find source code: github.com/Fundootesters/RestAssuredFramework/blob/master/src/main/java/utils/ParseDynamicJson.java.
      Stay tuned with fun doo testers.

    • @bathulanagendra4621
      @bathulanagendra4621 Před 4 lety +1

      @@FunDooTesters Thank you so much sir for sharing code.

  • @nareshkeeplearing655
    @nareshkeeplearing655 Před 3 lety +1

    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

    • @FunDooTesters
      @FunDooTesters  Před 3 lety +1

      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

  • @pankajmodi426
    @pankajmodi426 Před rokem

    bro i am using this code but getting lots of error, JSONObject.has(); json.keys(); etc having error ,,,plz suggest proper library

  • @ADITYACOOL90
    @ADITYACOOL90 Před 4 lety

    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?

    • @FunDooTesters
      @FunDooTesters  Před 4 lety +3

      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 czcams.com/video/xvg74eXR66I/video.html
      Need to figure out based on scenarios

    • @ADITYACOOL90
      @ADITYACOOL90 Před 4 lety

      @@FunDooTesters Thanks Nishant.Can you please upload the code on github.

  • @yelloverz5537
    @yelloverz5537 Před 4 lety

    Sooper cool... But it is more better if you can adjust the subtitle... It will improves the readability..

  • @viratsuresh5946
    @viratsuresh5946 Před rokem

    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.

    • @FunDooTesters
      @FunDooTesters  Před rokem

      Key= employee object I’d
      Value= employe object.
      If you can share complete data I can help

  • @komalsudhirshinde7601
    @komalsudhirshinde7601 Před 2 lety

    Which dependency u have used for jsonobject at 3:29 I am using json simple vala but it is throwing me error

    • @FunDooTesters
      @FunDooTesters  Před 2 lety

      Hi Komal,
      Here is a pom.XML github.com/Fundootesters/RestAssuredFramework/blob/master/pom.xml
      I hope it will help you

  • @yashbansal2526
    @yashbansal2526 Před 4 lety

    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!

    • @FunDooTesters
      @FunDooTesters  Před 4 lety +2

      It will automatically come when you paste json as a string in your IDE.

    • @yashbansal2526
      @yashbansal2526 Před 4 lety

      @@FunDooTesters thanks! You are doing a great job, keep it up👏

  • @subhrasarkar517
    @subhrasarkar517 Před 2 lety

    Hello, how are you converting a json input into string value in eclipse?

    • @FunDooTesters
      @FunDooTesters  Před 2 lety

      It will automatically considered as string if you declare as string.

  • @thinkjava4807
    @thinkjava4807 Před rokem

    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..

    • @FunDooTesters
      @FunDooTesters  Před rokem +1

      Store data in pojo share use shared object, that should solve purpose

    • @Subomb95
      @Subomb95 Před rokem

      Please help us to know how we can achieve it

  • @mariemzarai3969
    @mariemzarai3969 Před 2 lety

    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

    • @FunDooTesters
      @FunDooTesters  Před 2 lety

      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

  • @RahulSaini-ji1pn
    @RahulSaini-ji1pn Před rokem

    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?

    • @FunDooTesters
      @FunDooTesters  Před rokem

      You can write store values in desire collection like list or hasmap even pojo will work

  • @rameshanantha6280
    @rameshanantha6280 Před 8 měsíci

    Hi Anna
    Method is not working fine when we return the value instead of printing it
    Can you please help on it

  • @mattrex002
    @mattrex002 Před 2 lety

    I am not able to get some of the static methods that you are using when I used the simple JSON from Google

    • @FunDooTesters
      @FunDooTesters  Před 2 lety

      Checkout pom github.com/Fundootesters/RestAssuredFramework/blob/master/pom.xml

  • @ishansharma3741
    @ishansharma3741 Před rokem

    How to get Unique values , like i need id at 2nd place only as String not all values of key id

  • @vikrantmukkawar9737
    @vikrantmukkawar9737 Před 3 lety

    Nice Tutorial can you make video on java object to json using GSON for nested object and array with some complexity

  • @ivanbagsit1709
    @ivanbagsit1709 Před rokem

    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!

  • @johnlin9880
    @johnlin9880 Před měsícem

    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

    • @FunDooTesters
      @FunDooTesters  Před měsícem

      What do you have as an input, JSON schema?

  • @ravipathak2217
    @ravipathak2217 Před 22 dny

    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

  • @kanikajain2785
    @kanikajain2785 Před 3 lety

    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

    • @amir208501
      @amir208501 Před rokem

      Did you get a solution for this problem? If you did please share. How to get getKey() method to return list. Thank you,

  • @senthilrr8742
    @senthilrr8742 Před 2 lety

    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

  • @shameem132
    @shameem132 Před 3 lety +1

    Please tell me how to create dynamic function to update the jaon value in json file..thank you in advance...

    • @FunDooTesters
      @FunDooTesters  Před 3 lety

      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.

  • @yashpalwaghmare1701
    @yashpalwaghmare1701 Před 3 lety +1

    This is one of the best video I have seen, excellent explanations. Could I get the git repo url for this.?

    • @FunDooTesters
      @FunDooTesters  Před 3 lety +1

      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

    • @yashpalwaghmare1701
      @yashpalwaghmare1701 Před 3 lety

      @@FunDooTesters Thank you, sure I will do that.

    • @yashpalwaghmare1701
      @yashpalwaghmare1701 Před 3 lety

      @@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.

    • @FunDooTesters
      @FunDooTesters  Před 3 lety

      Did not get you. COuld you please share more details?

  • @kanishkatyagi4708
    @kanishkatyagi4708 Před 3 lety

    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?

    • @FunDooTesters
      @FunDooTesters  Před 3 lety

      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

    • @brahmananda8962
      @brahmananda8962 Před 3 lety

      @@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

    • @manasagakkala6556
      @manasagakkala6556 Před 3 lety

      Were you able to resolve this scenario?

  • @ajaykumar-xy6pw
    @ajaykumar-xy6pw Před 4 lety +1

    Can we use blob and clob objects in the json response as well, will it work with that as well?

    • @FunDooTesters
      @FunDooTesters  Před 4 lety +1

      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

    • @ajaykumar-xy6pw
      @ajaykumar-xy6pw Před 4 lety +2

      @@FunDooTesters thanks for responding quickly, can you please provide suggestions how can I mask and unmask the dynamically generated json data.

    • @FunDooTesters
      @FunDooTesters  Před 4 lety

      You can do with gson or regix pattern

  • @ashwinikantule146
    @ashwinikantule146 Před 2 lety

    Thank u for the code, can u pls explain how to pass multi form data with complex json objects to rest api.. Thanks

  • @payaljindal1621
    @payaljindal1621 Před 4 měsíci

    Hi Fundoo will u pls help with my JSON as it is little different from yours and parsing root is also different

    • @FunDooTesters
      @FunDooTesters  Před 3 měsíci

      Please share take a look github.com/Fundootesters/RestAssuredFramework/blob/master/src/main/java/utils/ParseDynamicJson.java once

  • @soumyaranjansahoo2667
    @soumyaranjansahoo2667 Před 2 lety

    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.

    • @FunDooTesters
      @FunDooTesters  Před 2 lety

      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

  • @Lakshmisridhar
    @Lakshmisridhar Před 3 lety +3

    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.

    • @FunDooTesters
      @FunDooTesters  Před 3 lety +3

      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.

    • @jagadishkounder96
      @jagadishkounder96 Před 3 lety +1

      Waiting for the same bro..

    • @shashwatkatiyar1377
      @shashwatkatiyar1377 Před 3 lety

      Hi,
      When will you upload the video ..Please help us

    • @ivangoh4883
      @ivangoh4883 Před 3 lety

      @@FunDooTesters Hi, may I know if you have the solution for this? Thank you.

    • @bhagyashreenavarkar8656
      @bhagyashreenavarkar8656 Před 2 lety

      @@FunDooTesters Did you upload video for the same?

  • @manojlonar4912
    @manojlonar4912 Před 4 lety

    Hi Nishant,
    Thanks for the wonderful tutorial...
    How can I pass "Response response" as arguement instead of JSON in the method?

    • @FunDooTesters
      @FunDooTesters  Před 4 lety

      Could you please elaborate. I did not get it.

    • @zafferali4415
      @zafferali4415 Před 4 lety

      @@FunDooTesters I have the same question. I will elaborate. In rest assured, if send a request, we capture the response using Response class with some object.
      Example:
      Response response = request.request(Method.GET, "/");

    • @ramyaaddepalli6832
      @ramyaaddepalli6832 Před 3 lety

      @@zafferali4415 Hi,you need to convert response object to string and then pass this string object to JSONObject

  • @adityakashyap6765
    @adityakashyap6765 Před 11 měsíci

    Can you make a video on updating the value for dynamic json?

  • @pragyanmishra-fl2vx
    @pragyanmishra-fl2vx Před 20 dny

    please provide these nested json files you have used. it will help me while learning on my eclipse IDE.

  • @mattrex002
    @mattrex002 Před 2 lety

    what is the dependency you are using in your POM ?

    • @FunDooTesters
      @FunDooTesters  Před 2 lety

      Take a look github.com/Fundootesters/RestAssuredFramework/blob/master/pom.xml

  • @hdkloh6857
    @hdkloh6857 Před 3 lety +1

    Why don't you use Hashmap instead? esp for the dynamic json objects

  • @vinamungekar
    @vinamungekar Před 2 lety

    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.

    • @FunDooTesters
      @FunDooTesters  Před 2 lety

      Not able to understand your problem statement completely. Try sorting and comparator. It should work

    • @vinamungekar
      @vinamungekar Před 2 lety

      @@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.

    • @NishantGohel
      @NishantGohel Před 2 lety

      @@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

    • @vinamungekar
      @vinamungekar Před 2 lety

      @@NishantGohel is your mail id available...i can explain it to you better

  • @saurabhsanyal4218
    @saurabhsanyal4218 Před rokem +1

    It's 4 in the morning just want to thank you, can I buy you a cup of coffee?

  • @natrajp4926
    @natrajp4926 Před 4 lety +1

    Hi Nishant, Thanks for the video tutorial.it really helps.I have scenarios like having same key in json object and Json array ..how to get value in json array (Ex: {"name":"john","cars":[{"name":"ford"}]}).please help

    • @FunDooTesters
      @FunDooTesters  Před 4 lety

      Please let me know, Which scenarios you are going to perform?

    • @natrajp4926
      @natrajp4926 Před 4 lety

      @@FunDooTesters I am having json like this {"name":"john","cars":[{"name":"ford"}]} ..i need to get the value of key : name

    • @FunDooTesters
      @FunDooTesters  Před 4 lety +1

      This code should work for same

  • @sushiltiwari274
    @sushiltiwari274 Před 2 lety

    If it is related to specific object like If I want phone number of particular student then what will be the way

    • @FunDooTesters
      @FunDooTesters  Před 2 lety

      You have to search student name first thn within that object or list go for phone number. Think like nested array

  • @yoshitamahajan353
    @yoshitamahajan353 Před rokem

    How to exit from this program when we have got the required value for the key?

  • @anilpal4338
    @anilpal4338 Před 2 lety

    Which Json library are you using is it open-source??

    • @FunDooTesters
      @FunDooTesters  Před 2 lety

      Yes it is free org.Json please have a look below github.com/Fundootesters/RestAssuredFramework/blob/master/pom.xml

  • @MrMadhur18
    @MrMadhur18 Před 4 lety

    Awesome video, can we pass direct json file not json as string ?

  • @jayeshjain6052
    @jayeshjain6052 Před 3 lety

    can i put file in place of pasting the string in json

  • @padmasreefidogroups2364

    in code i got error like json cannot be resolved what should i do?

  • @yoshitamahajan353
    @yoshitamahajan353 Před rokem

    Also can you please make video on how to parse json to java bean for dynamic json

  • @naziakaushar273
    @naziakaushar273 Před 3 lety

    I am getting ClassCastException in getKeys() at line 5

  • @Gaurav.Tripathi1
    @Gaurav.Tripathi1 Před rokem

    what is it's advantage over jsonpath ?

    • @FunDooTesters
      @FunDooTesters  Před rokem

      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

  • @manalijedhe7729
    @manalijedhe7729 Před 3 lety +1

    How to remove specific elements from simple.jsonObject? Remove not working