Standard format for planet_feeds.txt
patricoferris opened this issue · 9 comments
Currently when generating https://ocaml.org/community/planet/ the planet_feeds.txt is read in order to get the name and the RSS feed URL, the format of that file seems a little arbitrary (or perhaps was made before all of the nice JSON/Yaml/S-expression tools we now have were created!).
For ease of sharing this information, extending the information (e.g. adding descriptions), porting it elsewhere and maintainability I think we should convert planet_feeds.txt
to JSON.
As far as I can tell, we already transitively depend on ezjsonm
because we depend on COW so this would be a good library to use for the parsing (we will still add it to the .opam
file but it won't change the amount of things we pull in which is a nice bonus).
@patricoferris I would like to work on this :)
This is an opportunity to get familiar with ocaml indept. @patricoferris If it's not assigned to anyone I'd like to give it a try
@mahakbansal2019 is currently assigned, are you still working on this @mahakbansal2019?
No @patricoferris!
@mercybassey you can go ahead :)
Okay thanks
@mercybassey Are you still working on it? Do you need any help? :)
@gs0510 I tried requiring the package as shown in the ezjsonm readme but it didn't work , so I'm still not sure how to get it to work
Hello @patricoferris @gs0510. Since I am not yet familiar with the ezjsonm package I tried a different approach in converting the text file to JSON. All i did was to setup a node project, and used a library called text-to-json for the parsing. I installed the package via npm and required it. I'd like to know your take on this and also like to know if using the ezjsonm package follow the same approach. If not i will like to have a guide.
Hi @mercybassey,
Nice work so far, unfortunately I don't think we're going to add all of Node as another dependency. However, this is actually a really useful stepping stone that you can use.
I think the goals have been a little mixed up. This issue seeks to (a) convert the text document to JSON like you did with the Node project and save it to a file (plant_feeds.json
) and then (b) convert the logic in the OCaml scripts which used to read the bespoke text format to read JSON. Does that make sense? So Ezjsonm
would be used to read the file that is already JSON.
A small example:
utop -require ezjsonm
Then (ignore the escaping of double-quotes):
utop # let json = "[ { \"url\": \"https://ocaml.org\" } ]";;
val json : string = "[ { \"url\": \"https://ocaml.org\" } ]"
utop # let ez = Ezjsonm.value_from_string json;;
Ezjsonm.value = `A [`O [("url", `String "https://ocaml.org")]]