2017-04-08 98 views
0

我發現一個ACID Akaline xls文件將其轉換爲json。重新映射,重建json到自定義結構

但它給我。

[{ 
    "Most_Alkaline": "Baking Soda", 
    "More_Alkaline": "Spices/Cinnamon", 
    "Low_Alkaline": "•Herbs (most): Arnica,", 
    "Lowest_Alkaline": "White Willow Bark", 
    "Food_Category": "Spice/Herb", 
    "Lowest_Acid": "Curry", 
    "Low_Acid": "Vanilla", 
    "More_Acid": "Nutmeg", 
    "Most_Acid": "Pudding/Jam/Jelly" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "Valerian", 
    "Low_Alkaline": "Bergamot, Echinacea", 
    "Lowest_Alkaline": "Slippery Elm", 
    "Food_Category": "1", 
    "Lowest_Acid": "", 
    "Low_Acid": "Stevia", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "Licorice", 
    "Low_Alkaline": "Chrysanthemum,", 
    "Lowest_Alkaline": "Artemesia Annua", 
    "Food_Category": "2", 
    "Lowest_Acid": "", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "•Black Cohash", 
    "Low_Alkaline": "Ephedra, Feverfew,", 
    "Lowest_Alkaline": "", 
    "Food_Category": "3", 
    "Lowest_Acid": "", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "Agave", 
    "Low_Alkaline": "Goldenseal,", 
    "Lowest_Alkaline": "", 
    "Food_Category": "4", 
    "Lowest_Acid": "", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "Lemongrass", 
    "Lowest_Alkaline": "", 
    "Food_Category": "5", 
    "Lowest_Acid": "", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "Aloe Vera", 
    "Lowest_Alkaline": "", 
    "Food_Category": "6", 
    "Lowest_Acid": "", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "Nettle", 
    "Lowest_Alkaline": "", 
    "Food_Category": "7", 
    "Lowest_Acid": "", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "Angelica", 
    "Lowest_Alkaline": "", 
    "Food_Category": "8", 
    "Lowest_Acid": "", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "Sea Salt", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "Sulfite", 
    "Food_Category": "Preservative", 
    "Lowest_Acid": "MSG", 
    "Low_Acid": "Benzoate", 
    "More_Acid": "Aspartame", 
    "Most_Acid": "Table Salt (NaCL)" 
}, { 
    "Most_Alkaline": "Mineral Water", 
    "More_Alkaline": "•Kambucha", 
    "Low_Alkaline": "•Green or Mu Tea", 
    "Lowest_Alkaline": "Ginger Tea", 
    "Food_Category": "Beverage", 
    "Lowest_Acid": "Kona Coffee", 
    "Low_Acid": "Alcohol", 
    "More_Acid": "Coffee", 
    "Most_Acid": "Beer, 'Soda'" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "", 
    "Food_Category": "9", 
    "Lowest_Acid": "", 
    "Low_Acid": "Black Tea", 
    "More_Acid": "", 
    "Most_Acid": "Yeast/Hops/Malt" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "Molasses", 
    "Low_Alkaline": "Rice Syrup", 
    "Lowest_Alkaline": "•Sucanat", 
    "Food_Category": "Sweetner", 
    "Lowest_Acid": "Honey/MapleSyrup", 
    "Low_Acid": "", 
    "More_Acid": "Saccharin", 
    "Most_Acid": "Sugar/Cocoa" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "Soy Sauce", 
    "Low_Alkaline": "Apple Cider Vinegar", 
    "Lowest_Alkaline": "•Umeboshi Vinegar", 
    "Food_Category": "Vinegar", 
    "Lowest_Acid": "Rice Vinegar", 
    "Low_Acid": "Balsamic Vinegar", 
    "More_Acid": "Red Wine Vinegar", 
    "Most_Acid": "White/Acetic Vinegar" 
}, { 
    "Most_Alkaline": "•Umeboshi Plum", 
    "More_Alkaline": "", 
    "Low_Alkaline": "•Sake", 
    "Lowest_Alkaline": "•Algae, Blue Green", 
    "Food_Category": "Therapeutic", 
    "Lowest_Acid": "", 
    "Low_Acid": "Antihistamines", 
    "More_Acid": "Psychotropics", 
    "Most_Acid": "Antibiotics" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "•Ghee (Clarified", 
    "Food_Category": "Processed Dairy", 
    "Lowest_Acid": "Cream/Butter", 
    "Low_Acid": "Cow Milk", 
    "More_Acid": "•Casein, Milk", 
    "Most_Acid": "Processed Cheese" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "Butter)", 
    "Food_Category": "10", 
    "Lowest_Acid": "", 
    "Low_Acid": "", 
    "More_Acid": "Protein,Cottage", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "", 
    "Food_Category": "11", 
    "Lowest_Acid": "", 
    "Low_Acid": "", 
    "More_Acid": "Cheese", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "Human Breast Milk", 
    "Food_Category": "Cow/Human", 
    "Lowest_Acid": "Yogurt", 
    "Low_Acid": "Aged Cheese", 
    "More_Acid": "New Cheese", 
    "Most_Acid": "Ice Cream" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "", 
    "Food_Category": "Soy", 
    "Lowest_Acid": "", 
    "Low_Acid": "Soy Cheese", 
    "More_Acid": "Soy Milk", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "", 
    "Food_Category": "Goat/Sheep", 
    "Lowest_Acid": "Goat/Sheep Cheese", 
    "Low_Acid": "Goat Milk", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "•Quail Egg", 
    "Lowest_Alkaline": "•Duck Egg", 
    "Food_Category": "Egg", 
    "Lowest_Acid": "Chicken Egg", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "", 
    "Food_Category": "Meat", 
    "Lowest_Acid": "Gelatin/Organs", 
    "Low_Acid": "Lamb/Mutton", 
    "More_Acid": "Pork/Veal", 
    "Most_Acid": "Beef" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "", 
    "Food_Category": "Game", 
    "Lowest_Acid": "•Venison", 
    "Low_Acid": "Boar/Elk/•Game Meat", 
    "More_Acid": "Bear", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "", 
    "Food_Category": "Fish/Shell Fish", 
    "Lowest_Acid": "Fish", 
    "Low_Acid": "Mollusks", 
    "More_Acid": "•Mussel/Squid", 
    "Most_Acid": "Shell Fish (Processed)" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "", 
    "Food_Category": "12", 
    "Lowest_Acid": "", 
    "Low_Acid": "Shell Fish (Whole)", 
    "More_Acid": "", 
    "Most_Acid": "•Lobster" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "", 
    "Food_Category": "Fowl", 
    "Lowest_Acid": "Wild Duck", 
    "Low_Acid": "Goose/Turkey", 
    "More_Acid": "Chicken", 
    "Most_Acid": "Pheasant" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "Oat", 
    "Food_Category": "13", 
    "Lowest_Acid": "•Triticale", 
    "Low_Acid": "Buckwheat", 
    "More_Acid": "Maize", 
    "Most_Acid": "Barley" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "Grain Coffee'", 
    "Food_Category": "Grain", 
    "Lowest_Acid": "Millet", 
    "Low_Acid": "Wheat", 
    "More_Acid": "Barley Groat", 
    "Most_Acid": "Processed Flour" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "•Quinoa", 
    "Food_Category": "Cereal", 
    "Lowest_Acid": "Kasha", 
    "Low_Acid": "•Spelt/Teff/Kamut", 
    "More_Acid": "Corn", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "Wild Rice", 
    "Food_Category": "Grass", 
    "Lowest_Acid": "Brown Rice", 
    "Low_Acid": "Farina/Semolina", 
    "More_Acid": "Rye", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "•Amaranth", 
    "Food_Category": "14", 
    "Lowest_Acid": "", 
    "Low_Acid": "White Rice", 
    "More_Acid": "Oat Bran", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "Japonica Rice", 
    "Food_Category": "15", 
    "Lowest_Acid": "", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "Poppy Seed", 
    "Low_Alkaline": "Primrose Oil", 
    "Lowest_Alkaline": "Avocado Oil", 
    "Food_Category": "Nut", 
    "Lowest_Acid": "Pumpkin Seed Oil", 
    "Low_Acid": "Almond Oil", 
    "More_Acid": "Pistachio Seed", 
    "Most_Acid": "•Cottonseed Oil/Meal" 
}, { 
    "Most_Alkaline": "Pumpkin Seed", 
    "More_Alkaline": "Cashew", 
    "Low_Alkaline": "Sesame Seed", 
    "Lowest_Alkaline": "Seeds (most)", 
    "Food_Category": "Seed/Sprout", 
    "Lowest_Acid": "Grape Seed Oil", 
    "Low_Acid": "Sesame Oil", 
    "More_Acid": "Chestnut Oil", 
    "Most_Acid": "Hazelnut" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "Chestnut", 
    "Low_Alkaline": "Cod Liver Oil", 
    "Lowest_Alkaline": "Coconut Oil", 
    "Food_Category": "Oil", 
    "Lowest_Acid": "Sunflower Oil", 
    "Low_Acid": "Safflower Oil", 
    "More_Acid": "Lard", 
    "Most_Acid": "Walnut" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "Pepper", 
    "Low_Alkaline": "Almond", 
    "Lowest_Alkaline": "Olive/Macadamia Oil", 
    "Food_Category": "", 
    "Lowest_Acid": "Pine Nut", 
    "Low_Acid": "Tapioca", 
    "More_Acid": "Pecan", 
    "Most_Acid": "Brazil Nut" 
}, { 
    "Most_Alkaline": "Hydrogenated Oil", 
    "More_Alkaline": "", 
    "Low_Alkaline": "•Sprout", 
    "Lowest_Alkaline": "Linseed/Flax Oil", 
    "Food_Category": "", 
    "Lowest_Acid": "Canola Oil", 
    "Low_Acid": "•Seitan or Tofu", 
    "More_Acid": "Palm Kernel Oil", 
    "Most_Acid": "Fried Food" 
}, { 
    "Most_Alkaline": "Lentil", 
    "More_Alkaline": "Kohlrabi", 
    "Low_Alkaline": "Potato/Bell Pepper", 
    "Lowest_Alkaline": "Brussel Sprout", 
    "Food_Category": "16", 
    "Lowest_Acid": "Spinach", 
    "Low_Acid": "Split Pea", 
    "More_Acid": "Green Pea", 
    "Most_Acid": "Soybean" 
}, { 
    "Most_Alkaline": "Brocoflower", 
    "More_Alkaline": "Parsnip/Taro", 
    "Low_Alkaline": "Mushroom/Fungi", 
    "Lowest_Alkaline": "Beet", 
    "Food_Category": "Bean", 
    "Lowest_Acid": "Fava Bean", 
    "Low_Acid": "Pinto Bean", 
    "More_Acid": "Peanut", 
    "Most_Acid": "Carob" 
}, { 
    "Most_Alkaline": "•Seaweed", 
    "More_Alkaline": "Garlic", 
    "Low_Alkaline": "Cauliflower", 
    "Lowest_Alkaline": "Chive/Cilantro", 
    "Food_Category": "Vegetable", 
    "Lowest_Acid": "Kidney Bean", 
    "Low_Acid": "White Bean", 
    "More_Acid": "Snow Pea", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "Noril|Kombu|Wakame|Hijiki", 
    "More_Alkaline": "Asparagus", 
    "Low_Alkaline": "Cabbage", 
    "Lowest_Alkaline": "Celery/Scallion", 
    "Food_Category": "17", 
    "Lowest_Acid": "Black-eyed Pea", 
    "Low_Acid": "Navy/Red Bean", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "Onion/Miso", 
    "More_Alkaline": "Kale/Parsley", 
    "Low_Alkaline": "Rutabaga", 
    "Lowest_Alkaline": "Okra/Cucumber", 
    "Food_Category": "Legume", 
    "Lowest_Acid": "String/Wax Bean", 
    "Low_Acid": "Aduki Bean", 
    "More_Acid": "Legumes (other)", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "•Daikon/Taro Root", 
    "More_Alkaline": "Endive/Arugula", 
    "Low_Alkaline": "•Salsify/Ginseng", 
    "Lowest_Alkaline": "Turnip Greens", 
    "Food_Category": "Pulse", 
    "Lowest_Acid": "Zucchini", 
    "Low_Acid": "Lima or Mung Bean", 
    "More_Acid": "Carrot", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "•Sea Vegetables (other)", 
    "More_Alkaline": "Mustard Greens", 
    "Low_Alkaline": "Eggplant", 
    "Lowest_Alkaline": "Squash", 
    "Food_Category": "Root", 
    "Lowest_Acid": "Chutney", 
    "Low_Acid": "Chard", 
    "More_Acid": "ChickPea/Garbanzo", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "Dandelion Greens", 
    "More_Alkaline": "Jerusalem Artichoke", 
    "Low_Alkaline": "Pumpkin", 
    "Lowest_Alkaline": "Artichoke", 
    "Food_Category": "18", 
    "Lowest_Acid": "Rhubarb", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "•Burdock/•Lotus Root", 
    "More_Alkaline": "Ginger Root", 
    "Low_Alkaline": "Collard Greens", 
    "Lowest_Alkaline": "Lettuce", 
    "Food_Category": "19", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "Sweet Potato/Yam", 
    "More_Alkaline": "Broccoli", 
    "Low_Alkaline": "", 
    "Lowest_Alkaline": "Jicama", 
    "Food_Category": "20", 
    "Lowest_Acid": "", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "Lime", 
    "More_Alkaline": "Grapefruit", 
    "Low_Alkaline": "Lemon", 
    "Lowest_Alkaline": "Orange", 
    "Food_Category": "Citrus Fruit", 
    "Lowest_Acid": "Coconut", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "Nectarine", 
    "More_Alkaline": "Canteloupe", 
    "Low_Alkaline": "Pear", 
    "Lowest_Alkaline": "Apricot", 
    "Food_Category": "", 
    "Lowest_Acid": "Guava", 
    "Low_Acid": "Plum", 
    "More_Acid": "Cranberry", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "Persimmon", 
    "More_Alkaline": "Honeydew", 
    "Low_Alkaline": "Avocado", 
    "Lowest_Alkaline": "Most_Acid", 
    "Food_Category": "21", 
    "Lowest_Acid": "•Pickled Fruit", 
    "Low_Acid": "Prune", 
    "More_Acid": "Pomegranate", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "Raspberry", 
    "More_Alkaline": "Citrus", 
    "Low_Alkaline": "Apple", 
    "Lowest_Alkaline": "Blueberry", 
    "Food_Category": "22", 
    "Lowest_Acid": "Dry Fruit", 
    "Low_Acid": "Tomato", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "Watermelon", 
    "More_Alkaline": "Olive", 
    "Low_Alkaline": "Blackberry", 
    "Lowest_Alkaline": "Pineapple Juice", 
    "Food_Category": "Fruit", 
    "Lowest_Acid": "Fig", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "Tangerine", 
    "More_Alkaline": "•Dewberry", 
    "Low_Alkaline": "Cherry", 
    "Lowest_Alkaline": "Raisin, Currant", 
    "Food_Category": "23", 
    "Lowest_Acid": "Persimmon Juice", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "Pineapple", 
    "More_Alkaline": "Loganberry", 
    "Low_Alkaline": "Peach", 
    "Lowest_Alkaline": "Grape", 
    "Food_Category": "24", 
    "Lowest_Acid": "•Cherimoya", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}, { 
    "Most_Alkaline": "", 
    "More_Alkaline": "Mango", 
    "Low_Alkaline": "Papaya", 
    "Lowest_Alkaline": "Strawberry", 
    "Food_Category": "25", 
    "Lowest_Acid": "Date", 
    "Low_Acid": "", 
    "More_Acid": "", 
    "Most_Acid": "" 
}] 

我想完全用javascript重建它,看起來像。

[{ 
    "aliment": "Baking Soda", 
    "Food_Category": "Spice/Herb", 
    "alcide": "Low Alkaline", // alcide mean acid or alkaline 
    "score": "2", 
    "color": "green" 
}, { 
    "aliment": "apple", 
    "Food_Category": "fruits", 
    "alcide": "Most Acid", 
    "score": "-4", 
    "color": "red" 
}] 

費率可以建立如下。

Most Alkaline = 4 
More Alkaline = 3 
Low Alkaline = 2 
Lowest Alkaline = 1 
Lowest Acid = -1 
Low Acid = -2 
More Acid = -3 
Most Acid = -4 

red = Acid -1 -2 -3 -4 
green = Alkaline 1 2 3 4 

original xls我救在線:

+0

這不是我清楚你想要做什麼。如果你只有前兩個對象,你能舉出一個輸出的例子嗎?什麼會出來? – mfirry

+0

輸出示例在「我想完全用javascript重新構建它」。 – Gino

+0

你嘗試了什麼?郵政編碼,你已經嘗試過。什麼不適合你?一旦你知道如何用JavaScript讀取JSON文件,你應該能夠達到預期的效果。 – nkmol

回答

0

我得到了你想要做什麼。它可以通過一些代碼來實現。但是JSON文件非常混亂,這可能是由格式錯誤的Excel表格造成的,它需要很多工作。例如下面的行

"Lowest_Alkaline": "•Ghee (Clarified", 

甚至沒有完成。其餘的是陣列的下一個元素:

"Lowest_Alkaline": "Butter)", 

把它放在一起並不是一件容易的事。另一方面,如果您嘗試更改源xls文件,則更容易。您可以嘗試再次將其轉換爲JSON格式。

對不起,我忍不住,但我相信你應該嘗試第二個選項,其中包括重新設計的Excel文件。

好運

編輯

,我發現時間做到這一點,你可以下載它here

+0

我知道有人可以用javascript – Gino

+0

@gino找到一種方法,當然有。我能行。但我想我沒有讓自己清楚。我的意思是JSON文件是模糊和雜亂的,以及Excel文件。 至於你想要的輸出,還有另一個問題。在你的Excel文件中,Apple被表示爲「Low Alkaline - (2)」,而在你想要的輸出中,你寫了「Most Acid(-4)」 或者我可能會誤解。 –

+0

我做到了,只需從上面下載。 –