Giter Club home page Giter Club 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-json

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

a1764879 avatar adhikasp avatar arsfiqball avatar ava7 avatar awwsmm avatar bossbele avatar brianzbr avatar danwyry avatar drmonkeyninja avatar fitriani1021 avatar gbxyz avatar hashen110 avatar httpete-ire avatar husniddin avatar kevinrademan avatar kishiko avatar kuldipem avatar luke-john avatar ponting13 avatar raine avatar renovate-bot avatar samayo avatar techgaun avatar thebajanguy avatar ursuleacv avatar vheissu avatar wjdp avatar ykshatroff avatar z-fikar avatar zarifoudjibril avatar

Stargazers

 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.