samayo/country-json
Composer 安装命令:
composer require samayo/country-json
包简介
A simple but useful data of the world (by country) in JSON formats
README 文档
README
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:
- Country by Name
- Country by Abbreviation
- Country by Alphabet Letters
- Country by Avg Male Height
- Country by Barcode Prefix
- Country by Calling Code
- Country by Capital City
- Country by Cities
- Country by Continent
- Country by Coastline
- Country by Currency Name
- Country by Religion
- Country by Currency Code
- Country by Domain Tld
- Country by Driving Side
- Country by Elevation
- Country by Flag
- Country by Geo Coordinates
- Country by Government Type
- Country by Independence Date
- Country by Iso Numeric
- Country by Landlocked
- Country by Languages
- Country by Life Expectancy
- Country by National Symbol
- Country by National Dish
- Country by Population Density
- Country by Population
- Country by Region In World
- Country by Surface Area
- Country by Yearly Average Temperature
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
samayo/country-json 适用场景与选型建议
samayo/country-json 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 23.37k 次下载、GitHub Stars 达 1.15k, 最近一次更新时间为 2019 年 07 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「json」 「data」 「country」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 samayo/country-json 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 samayo/country-json 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 samayo/country-json 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Kinikit - PHP Application development framework MVC component
Sun Country is the package that helps you to get the country name & dialing code by the country ISO 3166-1 Alpha-2 code.
List of all countries with names and ISO 3166-1 codes in all languages and data formats for Laravel
Adds the EDTF data type to Wikibase
A simple library that allows transform any kind of data to native php data or whatever
统计信息
- 总下载量: 23.37k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1148
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-18