cuelang を試す
在宅勤務で生活リズムが変化し、しばらく勉強時間が取れなくなった。 早起きし朝を勉強に充てている。今週は職場で教えてもらった cuelang を試している。
今回できたのは著者リストと著作物リストの定義。このリストに惑わされ時間がかかった。 最終的なjsonをイメージしたところ、リストでなくオブジェクトだと気づいた。
authors_books
authors_books.cue
#Author: { id: string name: string } #Book: { id: string name: string author: #Author } authors: [ID=_]: { id: ID name: string } authors: kurt_vonnegut_jr: { name: "カート・ヴォネガット・ジュニア" } authors: arthur_charles_clarke: { name: "アーサー・チャールズ・クラーク" } books: [ID=_]: { id: ID name: string author: #Author } books: the_sirens_of_titan: { name: "タイタンの妖女" author: authors.kurt_vonnegut_jr } books: slaughterhouse_five: { name: "スローターハウス5" author: authors.kurt_vonnegut_jr } books: x2001_a_space_odyssey: { name: "2001年宇宙の旅" author: authors.arthur_charles_clarke } books: childhoods_end: { name: "幼年期の終り" author: authors.arthur_charles_clarke }
$ cue export authors_books.cue { "authors": { "kurt_vonnegut_jr": { "name": "カート・ヴォネガット・ジュニア", "id": "kurt_vonnegut_jr" }, "arthur_charles_clarke": { "name": "アーサー・チャールズ・クラーク", "id": "arthur_charles_clarke" } }, "books": { "the_sirens_of_titan": { "name": "タイタンの妖女", "id": "the_sirens_of_titan", "author": { "name": "カート・ヴォネガット・ジュニア", "id": "kurt_vonnegut_jr" } }, "slaughterhouse_five": { "name": "スローターハウス5", "id": "slaughterhouse_five", "author": { "name": "カート・ヴォネガット・ジュニア", "id": "kurt_vonnegut_jr" } }, "x2001_a_space_odyssey": { "name": "2001年宇宙の旅", "id": "x2001_a_space_odyssey", "author": { "name": "アーサー・チャールズ・クラーク", "id": "arthur_charles_clarke" } }, "childhoods_end": { "name": "幼年期の終り", "id": "childhoods_end", "author": { "name": "アーサー・チャールズ・クラーク", "id": "arthur_charles_clarke" } } } }