Git Product home page Git Product logo

country-json's Introduction

country>json Build Status

A simple data of the world (by country) each in JSON format.

Download

Using npm

$ npm install country-json

or composer

$ composer require samayo/country-data

or git

$ git clone https://github.com/samayo/country-json

List of contents provided in JSON formats:

Usage

Examples using various languages on how display/integrate the data.

PHP
$file = file_get_contents("./src/country-by-capital-city.json");

foreach (json_decode($file, true) as $key => $value) {
  var_dump($value); // { country: 'Afghanistan', city: 'Kabul' ..}
}
Node.js
var cities = require('./src/country-by-capital-city.json')

console.log(cities[0]); // { country: 'Afghanistan', city: 'Kabul' }
Ruby
require 'json'

file = File.read('./src/country-by-capital-city.json')
json = JSON.parse(file)

puts json[0] # {"country"=>"Afghanistan", "city"=>"Kabul"}
Python
import yaml

with open('./src/country-by-capital-city.json') as json_file:
    for line in yaml.safe_load(json_file):
        print line # {'country': 'Afghanistan', 'city': 'Kabul'}
Golang
package main

import (
  "encoding/json"
  "fmt"
  "io/ioutil"
)

func main() {
  data, err := ioutil.ReadFile("path/to/country-by-capital-city.json")
  if err != nil {
    panic(err)
  }

  var entries []struct{ Country, City string }
  if err = json.Unmarshal(data, &entries); err != nil {
    panic(err)
  }

  for _, entry := range entries {
    fmt.Println(entry.Country, entry.City)  # {'country': 'Afghanistan', 'city': 'Kabul'}
  }
}

Contribution

Feel free to send a PR to fix, update or add new entry anytime. For non-minor changes (ex: country: name, language, city, independence date..), please include a source, if possible.

Resources

country-json's People

Contributors

samayo avatar drmonkeyninja avatar vheissu avatar raine avatar techgaun avatar arsfiqball avatar husniddin avatar z-fikar avatar kuldipem avatar ava7 avatar adhikasp avatar kevinrademan avatar httpete-ire avatar ursuleacv avatar ykshatroff avatar danwyry avatar luke-john avatar fitriani1021 avatar wjdp avatar thebajanguy avatar discoshady avatar marianoguerra avatar kiranshahi avatar imbolc avatar hosein2398 avatar hannujaakkola avatar alissonenz avatar 41exio avatar a1764879 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.