quicktype將 JSON 和 GraphQL 數(shù)據(jù)快速生成模型代碼
quicktype 可將 JSON, schema 和 GraphQL 字符快速生成模型和序列化代碼,以便以任何編程語(yǔ)言快速安全地處理數(shù)據(jù)。
quicktype 可以生成 Objective-C, Swift 和 Java 等10幾種主流編程語(yǔ)言模型。
使用 quicktype
# Run quicktype without arguments for help and options
quicktype
# quicktype a simple JSON object in C#
echo '{ "name": "David" }' | quicktype -l csharp
# quicktype a top-level array and save as Go source
echo '[1, 2, 3]' | quicktype -o ints.go
# quicktype a sample JSON file in Swift
quicktype person.json -o Person.swift
# A verbose way to do the same thing
quicktype \
--src person.json \
--src-lang json \
--lang swift \
--top-level Person \
--out Person.swift
# quicktype a directory of samples as a C++ program
# Suppose ./blockchain is a directory with files:
# latest-block.json transactions.json marketcap.json
quicktype ./blockchain -o blockchain-api.cpp
# quicktype a live JSON API as a Java program
quicktype https://api.somewhere.com/data -o Data.java
評(píng)論
圖片
表情
