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
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.
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.
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