Issue converting imported json list of dicts from unicode to a list

Well, alright, it is the BOM. :sigh:

We should probably make system.file.readFilesAsString() better at that, somehow. In the meantime, something like this should work:

bytes = system.file.readFileAsBytes("/Users/pgriffith/Downloads/Three Parameter Model Data.json")

from org.apache.commons.io.input import BOMInputStream
from java.io import ByteArrayInputStream, ByteArrayOutputStream
from java.lang import String

bomInput = BOMInputStream(ByteArrayInputStream(bytes))
outputStream = ByteArrayOutputStream(len(bytes))
bomInput.transferTo(outputStream)
bytesOut = outputStream.toByteArray()
strOut = String(bytesOut, "utf-8")

print system.util.jsonDecode(strOut)

2 Likes

Thank you for the help! Appreciate it!

I will try this now, thank you!

Works thank you so much!

2 Likes