Python Forum
Python 3.5.2 & json on win 10
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3.5.2 & json on win 10
#11
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.
Reply
#12
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.
Reply
#13
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.
Reply
#14
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..
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#15
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.
Reply
#16
(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Split json into separate json based on node value CzarR 1 5,476 Jul-08-2022, 07:55 PM
Last Post: Larz60+
  difficulties to chage json data structure using json module in python Sibdar 1 2,044 Apr-03-2020, 06:47 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020