lzcjames / accessagriculture-googlemap

0 stars 0 forks source link

JSON Example, CSV to JSON #1

Open lzcjames opened 3 years ago

lzcjames commented 3 years ago
var json = [
  {
    "country": "Vanuatu",
    "lat": 15.3767,
    "lng": 166.9592,
    "description": "Vanuatu is a South Pacific Ocean nation made up of roughly 80 islands that stretch 1,300 kilometers.",
    "languages": [
      {
        "name": "English",
        "link": "http://example.com/en"
      },
      {
        "name": "French",
        "link": "http://example.com/fr"
      }
    ]
  },
  {
    "country": "Fiji",
    "lat": -16.578193,
    "lng": 179.414413,
    "description": "A country in the South Pacific, is an archipelago of more than 300 islands.",
    "languages": [
      {
        "name": "English",
        "link": "http://example.com/en"
      }
    ]
  },
  {
    "country": "Panama",
    "lat": 8.537981,
    "lng": -80.782127,
    "description": "A country on the isthmus linking Central and South America.",
    "languages": [
      {
        "name": "Spanish",
        "link": "http://example.com/es"
      }
    ]
  }
]

for (i = 0; i < json.length; i++) {
    for (j = 0; j < json[i]["languages"].length; j++) {
        console.log(json[i]["country"]+" "+json[i]["languages"][j]["name"] );
    }
}

Json formatter Working with JSON

JSON is a string whose format very much resembles JavaScript object literal format. Src1 : https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON Src2 : https://github.com/mdn/learning-area/blob/master/javascript/oojs/json/JSONTest.html

lzcjames commented 3 years ago

CSV to JSON: https://jsfiddle.net/301srzxq/4/