Thank you. I need to import this json and convert it to XML or CSV:
http://tribecafilm.com/api/xomo/films.json I'm guessing that the problem is the nested vector of cast members, which my project manager has asked me to flatten (I think she is planning work with this in Microsoft Excel, eventually). I start with rows like this: ;; ;; { ;; "Thumb_img_url":"https:\/\/s3.amazonaws.com\/tribeca_cms_production\/uploads\/uploads\/film\/photo_1\/513a82d1c07f5d4713000077\/small_odayaka__1_PUBS.jpg", ;; "website_url":"", ;; "director":"", ;; "large_img_url":null, ;; "youtube_url":"", ;; "title":"Odayaka", ;; "runtime":"100", ;; "id":"513a82d1c07f5d4713000077", ;; "categories":["Drama"], ;; "description":"The Great East Japan Earthquake has just struck, the waters of the ensuing tsunami finally rolling back into the sea. In the comparative safety of Tokyo, two wives and a child living in the same apartment building have nothing to do but wait for their husbands\u2019 return. Nobuteru Uchida finds a striking emotional core to the shock of March 11, 2011, crafting a tender and intelligent narrative on the internal effects of an unspeakable national tragedy.", ;; "cast": ;; [ ;; { ;; "_id":"513a82d1c07f5d4713000078", ;; "film_id":"513a82d1c07f5d4713000077", ;; "name":"Jo Keita, ;; Aya Saito", ;; "title":"Associate Producer" ;; }, ;; { ;; "_id":"513a82d1c07f5d4713000079", ;; "film_id":"513a82d1c07f5d4713000077", ;; "name":"Kiki Sugino, ;; Yukiko Shinohara, ;; Takeshi Yamamoto, ;; Ami Watanabe, ;; Yu Koyanagi, ;; Makiko Watanabe", ;; "title":"Cast" ;; }, ;; { ;; "_id":"513a82d1c07f5d471300007a", ;; "film_id":"513a82d1c07f5d4713000077", ;; "name":"Shinichi Tsunoda", ;; "title":"Cinematographer" ;; }, ;; { ;; "_id":"513a82d1c07f5d471300007b", ;; "film_id":"513a82d1c07f5d4713000077", ;; "name":"Jo Keita", ;; "title":"Composer" ;; }, ;; { ;; "_id":"513a82d1c07f5d471300007c", ;; "film_id":"513a82d1c07f5d4713000077", ;; "name":"Nobuteru Uchida", ;; "title":"Director" ;; }, ;; { ;; "_id":"513a82d1c07f5d471300007d", ;; "film_id":"513a82d1c07f5d4713000077", ;; "name":"Nobuteru Uchida", ;; "title":"Editor" ;; }, ;; { ;; "_id":"513a82d1c07f5d471300007e", ;; "film_id":"513a82d1c07f5d4713000077", ;; "name":"Kousuke Ono", ;; "title":"Executive Producer" ;; }, ;; { ;; "_id":"513a82d1c07f5d471300007f", ;; "film_id":"513a82d1c07f5d4713000077", ;; "name":"Kiki Sugino, ;; Eric Nyari", ;; "title":"Producer" ;; }, ;; { ;; "_id":"513a82d1c07f5d4713000080", ;; "film_id":"513a82d1c07f5d4713000077", ;; "name":"Nobuteru Uchida", ;; "title":"Screenwriter" ;; } ;; ] ;; }, I flattened this by inventing keys for the nested cast members. But now my different rows have different keys. I guess I should pad this so they all have the same rows? Or maybe I've missed something obvious? Seems like I shouldn't have to engage in ugly hacks for something this simple. On Friday, March 22, 2013 11:37:31 AM UTC-4, Gary Verhaegen wrote: > > I would guess the NPE comes from the form (xml/emit-str > (xml/map->Element next-movie-as-map)), given that (conj nil nil) does > not throw. > > Perhaps try to isolate the problem in a smaller chunk of code, and > then file a bug with the data.xml library? > > On 21 March 2013 19:16, larry google groups > <lawrenc...@gmail.com<javascript:>> > wrote: > > > > I am getting a null pointer exception in the line where I conj into the > > vector. I added the pprint so I could see what was going on. I am > confused > > by the outcome: > > > > (defn convert-json-to-xml [json-as-flat-maps] > > (reduce > > (fn [vector-of-strings next-movie-as-map] > > (println "next move as map: ") > > (println (pp/pprint next-movie-as-map)) > > (if (seq next-movie-as-map) > > (conj vector-of-strings (xml/emit-str (xml/map->Element > > next-movie-as-map))) > > vector-of-strings)) > > [] > > json-as-flat-maps)) > > > > The pprint is showing me this: > > > > {:film_64209.9096316473 "513e67e3c07f5dd745000051", > > :cast_member_64209.9096316473 "5148c50dc07f5db42300003a", > > :title_64209.9096316473 "Sound design", > > :director "", > > :runtime "5", > > :movie-id "513e67e3c07f5dd745000051", > > :title "Two Islands", > > :thumb > > > > " > https://s3.amazonaws.com/tribeca_cms_production/uploads/uploads/film/photo_1/513e67e3c07f5dd745000051/small_TWO_ISLANDS_2_pubs.jpg", > > > > :categories ["Documentary"], > > :youtube_url "", > > :website_url "", > > :name_64209.9096316473 "Svante Colérus", > > :description > > "Two Islands is film about two enormous waste dumps in New York City. > The > > first was once the largest dump in the world. The other, a cemetery of > > unknowns, is still in use. Two Islands bluntly asks, what does the > existence > > of these two huge mountains of economic and social waste and rejected > > surplus tell us about our civilization and the so-called richest nation > in > > the world? What kind of legacy will future archaeologists see?"} > > > > > > Any thoughts about what triggers a null pointer exception? I am using > this > > XML library: > > > > http://clojure.github.com/data.xml/ > > > > > > > > > > > > > > -- > > -- > > You received this message because you are subscribed to the Google > > Groups "Clojure" group. > > To post to this group, send email to clo...@googlegroups.com<javascript:> > > Note that posts from new members are moderated - please be patient with > your > > first post. > > To unsubscribe from this group, send email to > > clojure+u...@googlegroups.com <javascript:> > > For more options, visit this group at > > http://groups.google.com/group/clojure?hl=en > > --- > > You received this message because you are subscribed to the Google > Groups > > "Clojure" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to clojure+u...@googlegroups.com <javascript:>. > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.