Q: JsondecodeError: expecting value line 1 column 1 (char 0) at mqtt import paho.mqtt.client as mqtt
import pandas as pd
import json
import csv
import datetime
import os
import sys

def on_connect(client,userdata,flag,rc): //when connect to broker
    print("Connect",str(rc))
    print("client",client)
    print("flag= ",flag)

def on_message(client,userdata,message): //when received message 
    print(datetime.datetime.now())
    data = str(message.payload.decode("utf-8"))  //i think here is the error point..
    info = json.loads(data)["employees"]
 
    keylist = []
    for x in info[0].keys():
        keylist.append(x)
   

    df = pd.DataFrame(info,columns =keylist) #to add column so change json to dataframe
    df.insert(0,"received time",datetime.datetime.now()) #add the time
    keylist.append("received time")
  
    if os.path.isfile('/home/code/jsontocsvtest.csv'):
        csv = df.to_csv("jsontocsvtest.csv",index = False,mode='a',header = False)
    else:
        csv = df.to_csv("jsontocsvtest.csv",index = False,mode='a')

broker_address="0.0.0.0"
client1 = mqtt.Client("client1")
client1.on_connect = on_connect
client1.connect(broker_address)
client1.subscribe("outTopic") 
client1.on_message = on_message
client1.loop_forever()

I received JSON format messages and changed to dataframe to add columns and change to csv.
When I try this file in a short time it works , but after more second without sending from publisher, "Expecting value:line1 column 1 "error occur.
what is the problem?? decode error? how can i solve this problem??
