Closed kshitij10496 closed 5 years ago
Fixed in #12. The line that you have pointed to in the code doesn't worry about indentation, it's a dict object. We need to specify the indentation we need to the json.dump
function which is actually converting the dictionary to a string. 🙂
I see. Isn't there a way to associate the data formatting in the Encoder
class itself? 🤔
Oh man! I just don't like Python standard library's way of dealing with JSON anymore after learning Go. It all looks just so contrained. 😉
@themousepotato @Ayushk4 What do you guys think about this?
I agree with @icyflame . I can't find any way to make indentation in the Encoder
itself.
@kshitij10496 We could do it in the encoder class by adding a method called CourseEncoder.encodeToJson(courses)
. Sounds like a thing that the encoder class should do (and shouldn't be done outside the encoder class).
I think this could complicate things even further.
Let's use indent
keyword argument in the call to json.dumps
function as you suggested above.
A minor suggestion would be the addition of sort_keys
to maintain a uniformity in the resulting output. 😄
Currently, I'm encoding the data scrapped from the timetable directly into a JSON. This is an ad-hoc way just to get things done. Ideally, we would want to store the data into a beautiful format, similar to what
jq
does.Add indentation and formatting while encoding the scrapped data. This would involve modifying the
CourseEncoder
class.Refer: /data/scrapper/course_rooms.py