<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get dynamic Key and value from json file in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200525#M2986</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Are you able to use tExtractRegexFields component to get your key value?&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;Sabrina&lt;/P&gt;</description>
    <pubDate>Mon, 22 Oct 2018 10:54:02 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-10-22T10:54:02Z</dc:date>
    <item>
      <title>Get dynamic Key and value from json file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200524#M2985</link>
      <description>&lt;P&gt;I'm a Talend developer and i have a json files that contain a dynamic part and static part, my problem is in the dynamic part because i can't get the keys so i change to create a java class to get the&amp;nbsp; keys.&lt;BR /&gt;&lt;BR /&gt;my file is like this :&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;   [
    {
        "data": {
            "1801": "1801_13",
            "293954": "293954_1",
            "293985": "noir",
            "294071": "294071_3",
            "ean":  "5035915032563",
             "Nature": "450"            
        },
        
        "creation_date": "2018-08-28T12:25:06.638Z",
        "update_date": "2018-08-28T12:32:55.640Z",
       },

     {
        "data": {
            "2633": "1801_13",
            "293954": "293954_1",
            "ean":  "5035236232070",
            "Nature": "301"             
        },
        
        "creation_date": "2018-08-28T12:25:06.638Z",
        "update_date": "2018-08-28T12:32:55.640Z",
       }  ]&lt;/PRE&gt; 
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;data : dynamic part, and in this part i have two static keys (ena and nature) and the others keys are dynamic like this example.&lt;BR /&gt;I create a many class java but without success.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;i create this class java&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt; package routines;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    
    import org.json.JSONArray;
    import org.json.JSONException;
    import org.json.simple.JSONObject;
    import org.json.simple.parser.*;
    
    public class getKeyFromFile {
       
        
        
           
            public static void main(String filepath) throws ParseException, JSONException {
                JSONParser parser = new JSONParser();
              
                try {
             Object obj = parser.parse(new FileReader( filepath));
             JSONObject jsonObject = (JSONObject)obj ;
                        
              
                printJSON((JSONObject) jsonObject);
                } catch (FileNotFoundException e) {
    
                } catch (IOException ioe) {
    
                }       
            }
                public static void printJSON(JSONObject jsonObj) {
                    for (Object keyObj : jsonObj.keySet()) {
                        String key = (String)keyObj;
                        Object valObj = jsonObj.get(key);
                        if (valObj instanceof JSONObject) {
                            // call printJSON on nested object
                            printJSON((JSONObject) valObj);
                        } else {
                            // print key-value pair
                            System.out.println("key : "+key);
                            System.out.println("value : "+valObj.toString());
                        }
                    }
                }}&lt;/PRE&gt; 
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;i get this error :&lt;BR /&gt;&lt;BR /&gt;java.lang.ClassCastException: org.json.simple.JSONArray cannot be cast to org.json.JSONArray&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Can you help me please.&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Sep 2018 14:53:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200524#M2985</guid>
      <dc:creator>rid_rj</dc:creator>
      <dc:date>2018-09-18T14:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Get dynamic Key and value from json file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200525#M2986</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Are you able to use tExtractRegexFields component to get your key value?&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;Sabrina&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 10:54:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200525#M2986</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-10-22T10:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get dynamic Key and value from json file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200526#M2987</link>
      <description>&lt;P&gt;&lt;A href="https://community.qlik.com/s/profile/005390000062zUgAAI"&gt;@ridha_rjili&lt;/A&gt;: Did you end up getting any solution for this? Can you please share something?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 23:36:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200526#M2987</guid>
      <dc:creator>Parikhharshal</dc:creator>
      <dc:date>2018-11-13T23:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: Get dynamic Key and value from json file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200527#M2988</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any Solution to this scenario. Im looking for way to parse the json value dynamically. Please help.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 05:28:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200527#M2988</guid>
      <dc:creator>Anjali3</dc:creator>
      <dc:date>2022-03-14T05:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get dynamic Key and value from json file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200528#M2989</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Could you please elaborate your case with an example with input and expected output values? Which will be helpful for us to understand your requirement very well.&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Sabrina&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 06:54:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200528#M2989</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-14T06:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get dynamic Key and value from json file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200529#M2990</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My job should parse the JSON file to text file irrespective of the JSON structure. Job should dynamically parse it. Im trying to create a generic job for this use case. since I have 100 of JSON file with different structure. I don't want to create separate jobs for each of the file.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 19:55:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Get-dynamic-Key-and-value-from-json-file/m-p/2200529#M2990</guid>
      <dc:creator>Anjali3</dc:creator>
      <dc:date>2022-07-21T19:55:16Z</dc:date>
    </item>
  </channel>
</rss>

