QuinnDamerell / Baconit

A beatiful, powerful, reddit client for Windows 10.
https://www.reddit.com/r/BaconitDev/
GNU General Public License v2.0
242 stars 81 forks source link

Possible fix for parsing Subreddits's data when there are other objects (other than "data") inside a Subreddit's JSON (causing some Subreddits to be not possible to load from the app) #52

Closed eugeniopacceli closed 8 years ago

eugeniopacceli commented 8 years ago

Fixed MiscellaneousHelper.ParseOutRedditDataElement(string) for the case when there are other objects inside the JSON (other than the "data" object, thus other closing brackets). The original function would end the new json string after the first closing bracket was found, ending up with a invalid JSON string for the case when there were other closing brackets before the one closing the "data" object.

Exemple: https://www.reddit.com/r/relationships/about/.json

It was impossible to access /r/relationships duo to the malformed string generated by this function, which was causing a exception at Newtonsoft's Json Deserializer called by SubredditManager.GetSubredditFromWebByDisplayName(string), when it tried to parse this subreddit data.

However, instead of using MiscellaneousHelper.ParseOutRedditDataElement(string) to retrieve the Subreddit "data" object, the Json response was mapped to a class called SubredditAbout, allowing us to extract the actual Subreddit "data" object using Newtonsoft's Json Parser instead of direct string manipulation.

Possible solution for issue 51 https://github.com/QuinnDamerell/Baconit/issues/51

QuinnDamerell commented 8 years ago

Looks good thanks!