hhzl / LearnWords2

A word learning component (Leitner system) and word list conversion functions
MIT License
11 stars 2 forks source link

Add json2toml task #178

Closed hhzl closed 7 years ago

hhzl commented 7 years ago

https://www.npmjs.com/package/tomlify

https://runkit.com/npm/tomlify

JSON

var tomlify = require("tomlify");
var myobject = [{"_id":1,"word":"apple","translate":"der Apfel","tags":"fruit","picture":""},{"_id":2,"word":"pear","translate":"die Birne","tags":"fruit","picture":""},{"_id":3,"word":"lemon","translate":"die Zitrone","tags":"fruit","picture":""},{"_id":4,"word":"banana","translate":"die Banane","tags":"fruit","picture":""},{"_id":5,"word":"orange","translate":"die Orange","tags":"fruit","picture":""},{"_id":6,"word":"strawberry","translate":"die Erdbeere","tags":"fruit","picture":""},{"_id":7,"word":"raspberry","translate":"die Himbeere","tags":"fruit","picture":""},{"_id":8,"word":"blueberry","translate":"die Brombeere","tags":"fruit","picture":""},{"_id":9,"word":"guava","translate":"die Guava","tags":"fruit","picture":""},{"_id":10,"word":"pawpaw","translate":"die Papaya","tags":"fruit","picture":""},{"_id":11,"word":"apricot","translate":"die Aprikose","tags":"fruit","picture":""},{"_id":12,"word":"melon","translate":"die Melone","tags":"fruit","picture":""},{"_id":13,"word":"tomato","translate":"die Tomate","tags":"food","picture":""},{"_id":14,"word":"carrot","translate":"die Karotte","tags":"food","picture":""},{"_id":15,"word":"onion","translate":"die Zwiebel","tags":"food","picture":""},{"_id":16,"word":"rice","translate":"der Reis","tags":"food","picture":""},{"_id":17,"word":"salt","translate":"das Salz","tags":"food","picture":""},{"_id":18,"word":"oil","translate":"das Öl","tags":"food","picture":""},{"_id":19,"word":"flour","translate":"das Mehl","tags":"food","picture":""},{"_id":20,"word":"water","translate":"das Wasser","tags":"food","picture":""},{"_id":21,"word":"house","translate":"das Haus","tags":"building","picture":""},{"_id":22,"word":"a tree","translate":"ein Baum","tags":"nature","picture":""},{"_id":23,"word":"a river","translate":"ein Fluss","tags":"nature","picture":""},{"_id":24,"word":"the sun","translate":"die Sonne","tags":"nature","picture":""},{"_id":25,"word":"the moon","translate":"der Mond","tags":"nature","picture":""},{"_id":26,"word":"one star","translate":"ein Stern","tags":"nature","picture":""},{"_id":27,"word":"two stars","translate":"zwei Sterne","tags":"nature","picture":""},{"_id":28,"word":"three stars","translate":"drei Sterne","tags":"nature","picture":""},{"_id":29,"word":"four stars","translate":"vier Sterne","tags":"nature","picture":""},{"_id":30,"word":"five stars","translate":"fünf Sterne","tags":"nature","picture":""},{"_id":31,"word":"lion","translate":"der Löwe","tags":"animal","picture":"c10/lion.jpg"},{"_id":32,"word":"hyena","translate":"die Hyäne","tags":"animal","picture":"c10/hyena.jpg"},{"_id":33,"word":"goat","translate":"die Ziege","tags":"animal","picture":"c10/goat.jpg"},{"_id":34,"word":"cow","translate":"die Kuh","tags":"animal","picture":""},{"_id":35,"word":"cock","translate":"der Hahn","tags":"animal","picture":""},{"_id":36,"word":"hen","translate":"das Henne","tags":"animal","picture":"c10/hen.jpg"},{"_id":37,"word":"dog","translate":"der Hund","tags":"animal","picture":"c10/dog.jpg"},{"_id":38,"word":"donkey","translate":"der Esel","tags":"animal","picture":"c10/donkey.jpg"},{"_id":39,"word":"sheep","translate":"das Schaf","tags":"animal","picture":""},{"_id":40,"word":"dove","translate":"die Taube","tags":"animal","picture":""},{"_id":41,"word":"duck","translate":"die Ente","tags":"animal","picture":"c10/duck.jpg"},{"_id":42,"word":"fish","translate":"der Fisch","tags":"animal","picture":"c10/fish.jpg"},{"_id":43,"word":"toad","translate":"die Kröte","tags":"animal","picture":"c10/toad.jpg"},{"_id":44,"word":"cat","translate":"die Katze","tags":"animal","picture":"c10/cat.jpg"},{"_id":45,"word":"rabbit","translate":"der Hase","tags":"animal","picture":"c10/rabbit.jpg"},{"_id":46,"word":"man","translate":"der Mann","tags":"human","picture":""},{"_id":47,"word":"woman","translate":"die Frau","tags":"human","picture":""},{"_id":48,"word":"child","translate":"das Kind","tags":"human","picture":""},{"_id":49,"word":"cloth","translate":"der Stoff","tags":"household","picture":""},{"_id":50,"word":"sand","translate":"der Sand","tags":"building","picture":""},{"_id":51,"word":"pot","translate":"der Topf","tags":"household","picture":""},{"_id":52,"word":"soap","translate":"die Seife","tags":"household","picture":""},{"_id":53,"word":"book","translate":"das Buch","tags":"household","picture":""},{"_id":54,"word":"pencil","translate":"der Bleistift","tags":"household","picture":""},{"_id":55,"word":"nail","translate":"der Nagel","tags":"manmade","picture":""},{"_id":56,"word":"wood","translate":"Holz","tags":"building","picture":""},{"_id":57,"word":"car","translate":"das Auto","tags":"manmade","picture":""},{"_id":58,"word":"bridge","translate":"die Brücke","tags":"manmade","picture":""},{"_id":59,"word":"road","translate":"die Strasse","tags":"manmade","picture":""},{"_id":60,"word":"city","translate":"die Stadt","tags":"manmade","picture":""},{"_id":61,"word":"village","translate":"das Dorf","tags":"manmade","picture":""},{"_id":62,"word":"lamp","translate":"die Lampe","tags":"building","picture":""},{"_id":63,"word":"fire","translate":"das Feuer","tags":"household","picture":""},{"_id":64,"word":"tap","translate":"der Hahn","tags":"manmade","picture":""},{"_id":65,"word":"ship","translate":"das Schiff","tags":"manmade","picture":""},{"_id":66,"word":"cloud","translate":"die Wolke","tags":"nature","picture":""},{"_id":67,"word":"rain","translate":"der Regen","tags":"nature","picture":""},{"_id":68,"word":"ball","translate":"der Ball","tags":"household","picture":""},{"_id":69,"word":"window","translate":"das Fenster","tags":"building","picture":""},{"_id":70,"word":"door","translate":"die Türe","tags":"building","picture":""},{"_id":71,"word":"box","translate":"die Kiste","tags":"household","picture":""},{"_id":72,"word":"xylophone","translate":"das Xylophon","tags":"household","picture":""},{"_id":73,"word":"candle","translate":"die Kerze","tags":"household","picture":""},{"_id":74,"word":"ear","translate":"die Ähre","tags":"nature","picture":""},{"_id":75,"word":"hand","translate":"die Hand","tags":"human","picture":""},{"_id":76,"word":"foot","translate":"der Fuss","tags":"human","picture":""},{"_id":77,"word":"teeth","translate":"die Zähne","tags":"human","picture":""},{"_id":78,"word":"school","translate":"die Schule","tags":"manmade","picture":""},{"_id":79,"word":"hammer","translate":"der Hammer","tags":"manmade","picture":""},{"_id":80,"word":"spoon","translate":"der Löffel","tags":"household","picture":""},{"_id":81,"word":"bottle","translate":"die Flasche","tags":"household","picture":""},{"_id":82,"word":"sea","translate":"das Meer","tags":"nature","picture":""},{"_id":83,"word":"bus","translate":"der Bus","tags":"manmade","picture":""},{"_id":84,"word":"ear","translate":"das Ohr","tags":"human","picture":""}];
var toml = tomlify(myobject, {delims: true});

Result

+++
[_id = 1
word = "apple"
translate = "der Apfel"
tags = "fruit"
picture = ""
, _id = 2
word = "pear"
translate = "die Birne"
tags = "fruit"
picture = ""
, _id = 3
word = "lemon"
translate = "die Zitrone"
tags = "fruit"
picture = ""
, _id = 4
word = "banana"
translate = "die Banane"
tags = "fruit"
picture = ""
, _id = 5
word = "orange"
translate = "die Orange"
tags = "fruit"
picture = ""
, _id = 6
word = "strawberry"
translate = "die Erdbeere"
tags = "fruit"
picture = ""
, _id = 7
word = "raspberry"
translate = "die Himbeere"
tags = "fruit"
picture = ""
, _id = 8
word = "blueberry"
translate = "die Brombeere"
tags = "fruit"
picture = ""
, _id = 9
word = "guava"
translate = "die Guava"
tags = "fruit"
picture = ""
, _id = 10
word = "pawpaw"
translate = "die Papaya"
tags = "fruit"
picture = ""
, _id = 11
word = "apricot"
translate = "die Aprikose"
tags = "fruit"
picture = ""
, _id = 12
word = "melon"
translate = "die Melone"
tags = "fruit"
picture = ""
, _id = 13
word = "tomato"
translate = "die Tomate"
tags = "food"
picture = ""
, _id = 14
word = "carrot"
translate = "die Karotte"
tags = "food"
picture = ""
, _id = 15
word = "onion"
translate = "die Zwiebel"
tags = "food"
picture = ""
, _id = 16
word = "rice"
translate = "der Reis"
tags = "food"
picture = ""
, _id = 17
word = "salt"
translate = "das Salz"
tags = "food"
picture = ""
, _id = 18
word = "oil"
translate = "das Öl"
tags = "food"
picture = ""
, _id = 19
word = "flour"
translate = "das Mehl"
tags = "food"
picture = ""
, _id = 20
word = "water"
translate = "das Wasser"
tags = "food"
picture = ""
, _id = 21
word = "house"
translate = "das Haus"
tags = "building"
picture = ""
, _id = 22
word = "a tree"
translate = "ein Baum"
tags = "nature"
picture = ""
, _id = 23
word = "a river"
translate = "ein Fluss"
tags = "nature"
picture = ""
, _id = 24
word = "the sun"
translate = "die Sonne"
tags = "nature"
picture = ""
, _id = 25
word = "the moon"
translate = "der Mond"
tags = "nature"
picture = ""
, _id = 26
word = "one star"
translate = "ein Stern"
tags = "nature"
picture = ""
, _id = 27
word = "two stars"
translate = "zwei Sterne"
tags = "nature"
picture = ""
, _id = 28
word = "three stars"
translate = "drei Sterne"
tags = "nature"
picture = ""
, _id = 29
word = "four stars"
translate = "vier Sterne"
tags = "nature"
picture = ""
, _id = 30
word = "five stars"
translate = "fünf Sterne"
tags = "nature"
picture = ""
, _id = 31
word = "lion"
translate = "der Löwe"
tags = "animal"
picture = "c10/lion.jpg"
, _id = 32
word = "hyena"
translate = "die Hyäne"
tags = "animal"
picture = "c10/hyena.jpg"
, _id = 33
word = "goat"
translate = "die Ziege"
tags = "animal"
picture = "c10/goat.jpg"
, _id = 34
word = "cow"
translate = "die Kuh"
tags = "animal"
picture = ""
, _id = 35
word = "cock"
translate = "der Hahn"
tags = "animal"
picture = ""
, _id = 36
word = "hen"
translate = "das Henne"
tags = "animal"
picture = "c10/hen.jpg"
, _id = 37
word = "dog"
translate = "der Hund"
tags = "animal"
picture = "c10/dog.jpg"
, _id = 38
word = "donkey"
translate = "der Esel"
tags = "animal"
picture = "c10/donkey.jpg"
, _id = 39
word = "sheep"
translate = "das Schaf"
tags = "animal"
picture = ""
, _id = 40
word = "dove"
translate = "die Taube"
tags = "animal"
picture = ""
, _id = 41
word = "duck"
translate = "die Ente"
tags = "animal"
picture = "c10/duck.jpg"
, _id = 42
word = "fish"
translate = "der Fisch"
tags = "animal"
picture = "c10/fish.jpg"
, _id = 43
word = "toad"
translate = "die Kröte"
tags = "animal"
picture = "c10/toad.jpg"
, _id = 44
word = "cat"
translate = "die Katze"
tags = "animal"
picture = "c10/cat.jpg"
, _id = 45
word = "rabbit"
translate = "der Hase"
tags = "animal"
picture = "c10/rabbit.jpg"
, _id = 46
word = "man"
translate = "der Mann"
tags = "human"
picture = ""
, _id = 47
word = "woman"
translate = "die Frau"
tags = "human"
picture = ""
, _id = 48
word = "child"
translate = "das Kind"
tags = "human"
picture = ""
, _id = 49
word = "cloth"
translate = "der Stoff"
tags = "household"
picture = ""
, _id = 50
word = "sand"
translate = "der Sand"
tags = "building"
picture = ""
, _id = 51
word = "pot"
translate = "der Topf"
tags = "household"
picture = ""
, _id = 52
word = "soap"
translate = "die Seife"
tags = "household"
picture = ""
, _id = 53
word = "book"
translate = "das Buch"
tags = "household"
picture = ""
, _id = 54
word = "pencil"
translate = "der Bleistift"
tags = "household"
picture = ""
, _id = 55
word = "nail"
translate = "der Nagel"
tags = "manmade"
picture = ""
, _id = 56
word = "wood"
translate = "Holz"
tags = "building"
picture = ""
, _id = 57
word = "car"
translate = "das Auto"
tags = "manmade"
picture = ""
, _id = 58
word = "bridge"
translate = "die Brücke"
tags = "manmade"
picture = ""
, _id = 59
word = "road"
translate = "die Strasse"
tags = "manmade"
picture = ""
, _id = 60
word = "city"
translate = "die Stadt"
tags = "manmade"
picture = ""
, _id = 61
word = "village"
translate = "das Dorf"
tags = "manmade"
picture = ""
, _id = 62
word = "lamp"
translate = "die Lampe"
tags = "building"
picture = ""
, _id = 63
word = "fire"
translate = "das Feuer"
tags = "household"
picture = ""
, _id = 64
word = "tap"
translate = "der Hahn"
tags = "manmade"
picture = ""
, _id = 65
word = "ship"
translate = "das Schiff"
tags = "manmade"
picture = ""
, _id = 66
word = "cloud"
translate = "die Wolke"
tags = "nature"
picture = ""
, _id = 67
word = "rain"
translate = "der Regen"
tags = "nature"
picture = ""
, _id = 68
word = "ball"
translate = "der Ball"
tags = "household"
picture = ""
, _id = 69
word = "window"
translate = "das Fenster"
tags = "building"
picture = ""
, _id = 70
word = "door"
translate = "die Türe"
tags = "building"
picture = ""
, _id = 71
word = "box"
translate = "die Kiste"
tags = "household"
picture = ""
, _id = 72
word = "xylophone"
translate = "das Xylophon"
tags = "household"
picture = ""
, _id = 73
word = "candle"
translate = "die Kerze"
tags = "household"
picture = ""
, _id = 74
word = "ear"
translate = "die Ähre"
tags = "nature"
picture = ""
, _id = 75
word = "hand"
translate = "die Hand"
tags = "human"
picture = ""
, _id = 76
word = "foot"
translate = "der Fuss"
tags = "human"
picture = ""
, _id = 77
word = "teeth"
translate = "die Zähne"
tags = "human"
picture = ""
, _id = 78
word = "school"
translate = "die Schule"
tags = "manmade"
picture = ""
, _id = 79
word = "hammer"
translate = "der Hammer"
tags = "manmade"
picture = ""
, _id = 80
word = "spoon"
translate = "der Löffel"
tags = "household"
picture = ""
, _id = 81
word = "bottle"
translate = "die Flasche"
tags = "household"
picture = ""
, _id = 82
word = "sea"
translate = "das Meer"
tags = "nature"
picture = ""
, _id = 83
word = "bus"
translate = "der Bus"
tags = "manmade"
picture = ""
, _id = 84
word = "ear"
translate = "das Ohr"
tags = "human"
picture = ""
]+++
hhzl commented 7 years ago

http://binarymuse.github.io/toml-node/

{
  "words": [
    {
      "word": "apple",
      "translate": "der Apfel"
    },
    {
      "word": "mango",
      "translate": "die Mango"
    },
    {
      "word": "strawberry",
      "translate": "die Erdbeere"
    },
    {
      "word": "pear",
      "translate": "die Birne"
    }
  ]
}
[[words]]
word = "apple"
translate = "der Apfel"

[[words]]
word = "mango"
translate = "die Mango"

[[words]]
word = "strawberry"
translate = "die Erdbeere"

[[words]]
word = "pear"
translate = "die Birne"