Python Forum

Full Version: Python 3.5.2 & json on win 10
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Try making schedule.json an empty file on the Debian system, you'll get the same error as on Windows. I'm quite certain the Windows file is simply empty.
JUST GOT IT WORKING!

You guys were right about the json file.

This is what it looked like before formatting:
{"zones": [[1, 3], [3, 5], [5, 89]], "weekdays": [1, 2], "ontime": [5, 1]}

And this is what it looks like after formatting:
{
"zones":[
[
1,
3
],
[
3,
5
],
[
5,
89
]
],
"weekdays":[
1,
2
],
"ontime":[
5,
1
]
}

The only problem I see is it worked fine unformatted on a Linux system. But I gues it doesn't matter now because I have it working on Win 10.

Thanks for the pointers folks.

It is working!

After formatting the json file online, it works just fine.

The original file: {"zones": [[1, 3], [3, 5], [5, 89]], "weekdays": [1, 2], "ontime": [5, 1]}

The formatted file:
{
"zones":[
[
1,
3
],
[
3,
5
],
[
5,
89
]
],
"weekdays":[
1,
2
],
"ontime":[
5,
1
]
}

Not sure why the unformatted file works on linux but not win 10, but at least I got it working.

Thanks for the help folks.
I'm still convinced that the file was empty before, and was simply written due to this attempted workaround. Otherwise, when you tried to print it in between the <>, we would have seen the file.
Your json may have a BOM character at the beginning. Check it with a binary editor  (or zip it and attach here so that we can check; if you post it as text, this could drop the BOM and we wouldn't see it).

PS: Hazy memory of having similar problems on Windows, because Notepad++ would add BOMsto all UTF-8 files..
I believe you are correct.

I created another un-formatted json file and it worked.

I know it wasn't empty at first, but perhaps it had some kind of invalid non-printable character at the beginning.

In any case, thanks for your help.
(Nov-28-2016, 06:01 PM)PickyBiker Wrote: [ -> ]I know it wasn't empty at first, but perhaps it had some kind of invalid non-printable character at the beginning.
How do you know this? In this post, when "<>" is printed, the file clearly does not contain the JSON. It may also have had non-printable character, but there was no JSON in there.
Pages: 1 2