The JSON sent by Firebase is invalid
<pre><code>{ name: 'anonymous', text: 'Hello' }
{ name: 'anonymous', text: 'How are you' }
{ name: 'anonymous', text: 'I am fine' }
</code></pre>

<p>This code is returned by Firebase and I'm getting the error <code>No JSON object could be decoded</code>. I think this has to do something with the validity of the JSON format.</p>

<p>I'm getting this JSON data using the Firebase Node.JS SDK. Then I'm passing it to Python using Pyshell. When I use the <code>json.loads</code> in python, tt says:</p>

<pre><code>C:\Python27&gt;node firebase2.js
{ name: 'anonymous', text: 'Hello' }
{ name: 'anonymous', text: 'How are you' }
{ name: 'anonymous', text: 'I am fine' }
C:\Python27\firebase2.js:40
          if (err) throw err;
                   ^

Error: ValueError: No JSON object could be decoded
    at PythonShell.parseError (C:\Python27\node_modules\python-shell\index.js:183:17)
    at terminateIfNeeded (C:\Python27\node_modules\python-shell\index.js:98:28)
    at ChildProcess.&lt;anonymous&gt; (C:\Python27\node_modules\python-shell\index.js:88:9)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
    ----- Python Traceback -----
    File "my_script.py", line 3, in &lt;module&gt;
      myjson = json.loads(myinput)
    File "C:\Python27\lib\json\__init__.py", line 339, in loads
      return _default_decoder.decode(s)
    File "C:\Python27\lib\json\decoder.py", line 364, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File "C:\Python27\lib\json\decoder.py", line 382, in raw_decode
      raise ValueError("No JSON object could be decoded")
</code></pre>

<p>This is not a valid JSON and I think that your <code>firebase2.js</code> is at fault here.</p>

<p>Instead of this:</p>

<pre><code>{ name: 'anonymous', text: 'Hello' }
{ name: 'anonymous', text: 'How are you' }
{ name: 'anonymous', text: 'I am fine' }
</code></pre>

<p>It should output this:</p>

<pre><code>[
  { "name": "anonymous", "text": "Hello" },
  { "name": "anonymous", "text": "How are you" },
  { "name": "anonymous", "text": "I am fine" }
]
</code></pre>

<p>All strings (including object keys) have to be quoted with double quotes. Arrays have to be included in square brackets and array elements need to be delimited with commas.</p>

<p>Check out your <code>firebase2.js</code> program and see how it generates its output. If it uses anything else than a single:</p>

<pre><code>console.log(JSON.stringify(SOME_VARIABLE));
</code></pre>

<p>Then here's your problem.</p>

<p>In any case, I am more than sure that Firebase is not returning 
<code>{a:'b'}{c:'d'}</code> instead of <code>[{"a":"b"},{"c":"d"}]</code> - this is a typical error of beginners who don't know the JSON format, something hard to believe in the case of one of the biggest API providers in the world.</p>

<p>If you want to know what is the real response then use <code>curl</code>:</p>

<pre><code>curl -v https://example.com/some/endpoint -H 'auth header' ...
</code></pre>

<p>and if you see invalid JSON there, then it's time to contact Firebase support.</p>

<p>The JSON format is explained on <a href="http://json.org/" rel="nofollow">http://json.org/</a> - this is the simplest data format in existence.</p>

python json node.js firebase firebase-cloud-messaging