EDIT
For anyone else looking for this in the future the change I had to make was in the Python side, using pyserial instead of the version provided by the webiopi.
This is the final code:
import serial
# Configure the serial port (replace with your port and baud rate)
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=1)
@webiopi.macro
def getSerialArduinoData():
json = ""
webiopi.sleep(1)
ser.write(b'd') #send command "d" to request data from Arduino
data_bytes = ser.read_until(b'\n') # Read until the newline character
json = data_bytes.decode('utf-8') # Decode the bytes to a string
json = json.strip() # Remove the delimiter from the end
return json