<?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: my python output with Json format is enclosed with Unicode character and so splunk is not parsing properly the fields in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/my-python-output-with-Json-format-is-enclosed-with-Unicode/m-p/466989#M80452</link>
    <description>&lt;P&gt;@kamlesh_vaghela thanks , it worked with dumps.&lt;BR /&gt;
Please convert it into answer to accept it&lt;/P&gt;</description>
    <pubDate>Mon, 06 Apr 2020 10:28:06 GMT</pubDate>
    <dc:creator>DataOrg</dc:creator>
    <dc:date>2020-04-06T10:28:06Z</dc:date>
    <item>
      <title>my python output with Json format is enclosed with Unicode character and so splunk is not parsing properly the fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/my-python-output-with-Json-format-is-enclosed-with-Unicode/m-p/466985#M80448</link>
      <description>&lt;P&gt;I have python script configured in the HF , the script output are enclosed with unicode character U' in the output so splunk is unable to parse the fields properly.&lt;/P&gt;

&lt;P&gt;script output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{u'rows': [{u'timestamp': 1585924500001L, u'RAM_': 1000, u'Allocated': 4000.78, u'queue': 0, u'Details':  u'Connected': 2, u'Queue': 0, u'EventsQueue': 0}]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I had include in Props.conf for charset but still it was not parsing properly.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;props.conf&lt;BR /&gt;
 [sourcetype::GetStreamData]&lt;BR /&gt;
CHARSET=utf-8&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;[sourcetype::GetStreamData]&lt;BR /&gt;
CHARSET=utf-8&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 06:45:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/my-python-output-with-Json-format-is-enclosed-with-Unicode/m-p/466985#M80448</guid>
      <dc:creator>DataOrg</dc:creator>
      <dc:date>2020-04-06T06:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: my python output with Json format is enclosed with Unicode character and so splunk is not parsing properly the fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/my-python-output-with-Json-format-is-enclosed-with-Unicode/m-p/466986#M80449</link>
      <description>&lt;P&gt;@premranjithj &lt;/P&gt;

&lt;P&gt;Are you using &lt;CODE&gt;json.dumps&lt;/CODE&gt; in python file?? Can you please share your sample code ? &lt;/P&gt;

&lt;H2&gt;Updating Answer&lt;/H2&gt;

&lt;P&gt;Can you please replace &lt;CODE&gt;return json_obj&lt;/CODE&gt; with  &lt;CODE&gt;return json.dump(json_obj)&lt;/CODE&gt; and try ?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 07:11:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/my-python-output-with-Json-format-is-enclosed-with-Unicode/m-p/466986#M80449</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-04-06T07:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: my python output with Json format is enclosed with Unicode character and so splunk is not parsing properly the fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/my-python-output-with-Json-format-is-enclosed-with-Unicode/m-p/466987#M80450</link>
      <description>&lt;P&gt;@kamlesh_vaghela &lt;BR /&gt;
this is the code which i am using.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import requests
import json

headers={
        "accept": "application/json",
        "content-type": "application/json"
    }

test_urls = ['https://google.com']


def return_json(url):
    try:
        response = requests.get(url,headers=headers)

        # Consider any status other than 2xx an error
        if not response.status_code // 100 == 2:
            return "Error: Unexpected response {}".format(response)

        json_obj = response.json()
        return json_obj
    except requests.exceptions.RequestException as e:
        # A serious problem happened, like an SSLError or InvalidURL
        return "Error: {}".format(e)


for url in test_urls:

    print "Fetching URL '{}'".format(url)
    print return_json(url)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Apr 2020 08:45:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/my-python-output-with-Json-format-is-enclosed-with-Unicode/m-p/466987#M80450</guid>
      <dc:creator>DataOrg</dc:creator>
      <dc:date>2020-04-06T08:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: my python output with Json format is enclosed with Unicode character and so splunk is not parsing properly the fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/my-python-output-with-Json-format-is-enclosed-with-Unicode/m-p/466988#M80451</link>
      <description>&lt;P&gt;@premranjithj&lt;/P&gt;

&lt;P&gt;Can you please replace &lt;CODE&gt;return json_obj&lt;/CODE&gt; with  &lt;CODE&gt;return json.dump(json_obj)&lt;/CODE&gt; and try ?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 09:00:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/my-python-output-with-Json-format-is-enclosed-with-Unicode/m-p/466988#M80451</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-04-06T09:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: my python output with Json format is enclosed with Unicode character and so splunk is not parsing properly the fields</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/my-python-output-with-Json-format-is-enclosed-with-Unicode/m-p/466989#M80452</link>
      <description>&lt;P&gt;@kamlesh_vaghela thanks , it worked with dumps.&lt;BR /&gt;
Please convert it into answer to accept it&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 10:28:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/my-python-output-with-Json-format-is-enclosed-with-Unicode/m-p/466989#M80452</guid>
      <dc:creator>DataOrg</dc:creator>
      <dc:date>2020-04-06T10:28:06Z</dc:date>
    </item>
  </channel>
</rss>

