All Projects → robb → Rbbjson

robb / Rbbjson

Licence: mit
Flexible JSON traversal for rapid prototyping.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Rbbjson

Rumble
⛈️ Rumble 1.11.0 "Banyan Tree"🌳 for Apache Spark | Run queries on your large-scale, messy JSON-like data (JSON, text, CSV, Parquet, ROOT, AVRO, SVM...) | No install required (just a jar to download) | Declarative Machine Learning and more
Stars: ✭ 58 (-62.58%)
Mutual labels:  json, data-science
Web Database Analytics
Web scrapping and related analytics using Python tools
Stars: ✭ 175 (+12.9%)
Mutual labels:  json, data-science
Handout
Turn Python scripts into handouts with Markdown and figures
Stars: ✭ 1,973 (+1172.9%)
Mutual labels:  data-science, prototyping
Dotnet Fake Json Server
Fake JSON Server is a Fake REST API that can be used as a Back End for prototyping or as a template for a CRUD Back End.
Stars: ✭ 265 (+70.97%)
Mutual labels:  json, prototyping
Specs
Technical specifications and guidelines for implementing Frictionless Data.
Stars: ✭ 403 (+160%)
Mutual labels:  json, data-science
Urs
Universal Reddit Scraper - A comprehensive Reddit scraping command-line tool written in Python.
Stars: ✭ 275 (+77.42%)
Mutual labels:  json, data-science
Elastic
R client for the Elasticsearch HTTP API
Stars: ✭ 227 (+46.45%)
Mutual labels:  json, data-science
Boltons
🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.
Stars: ✭ 5,671 (+3558.71%)
Mutual labels:  json, data-science
Just Dashboard
📊 📋 Dashboards using YAML or JSON files
Stars: ✭ 1,511 (+874.84%)
Mutual labels:  json, data-science
Benchm Ml
A minimal benchmark for scalability, speed and accuracy of commonly used open source implementations (R packages, Python scikit-learn, H2O, xgboost, Spark MLlib etc.) of the top machine learning algorithms for binary classification (random forests, gradient boosted trees, deep neural networks etc.).
Stars: ✭ 1,835 (+1083.87%)
Mutual labels:  data-science
Graspologic
Python package for graph statistics
Stars: ✭ 153 (-1.29%)
Mutual labels:  data-science
Gelatin
Transform text files to XML, JSON, or YAML
Stars: ✭ 150 (-3.23%)
Mutual labels:  json
Machine Learning With Python
Practice and tutorial-style notebooks covering wide variety of machine learning techniques
Stars: ✭ 2,197 (+1317.42%)
Mutual labels:  data-science
Go Tsne
t-Distributed Stochastic Neighbor Embedding (t-SNE) in Go
Stars: ✭ 153 (-1.29%)
Mutual labels:  data-science
The Python Workshop
A New, Interactive Approach to Learning Python
Stars: ✭ 150 (-3.23%)
Mutual labels:  data-science
Data Science Stack Cookiecutter
🐳📊🤓Cookiecutter template to launch an awesome dockerized Data Science toolstack (incl. Jupyster, Superset, Postgres, Minio, AirFlow & API Star)
Stars: ✭ 153 (-1.29%)
Mutual labels:  data-science
I18next Gettext Converter
converts gettext .mo or .po to 18next json format and vice versa
Stars: ✭ 150 (-3.23%)
Mutual labels:  json
Jose2go
Golang (GO) implementation of Javascript Object Signing and Encryption specification
Stars: ✭ 150 (-3.23%)
Mutual labels:  json
Open Solution Toxic Comments
Open solution to the Toxic Comment Classification Challenge
Stars: ✭ 154 (-0.65%)
Mutual labels:  data-science
Poison
An incredibly fast, pure Elixir JSON library
Stars: ✭ 1,898 (+1124.52%)
Mutual labels:  json

RBBJSON

Swift Version: 5.2 Swift Package Manager Swift Package Manager Twitter: @DLX

RBBJSON enables flexible JSON traversal at runtime and JSONPath-like querying for rapid prototyping.

Use JSONDecoder to create an RBBJSON struct, then traverse it using dynamic member lookup:

let json = try JSONDecoder().decode(RBBJSON.self, from: data)

json.firstName         // RBBJSON.string("John")
json.lastName          // RBBJSON.string("Appleseed")
json.age               // RBBJSON.number(26)
json.invalidKey        // RBBJSON.null
json.phoneNumbers[0]   // RBBJSON.string("+14086065775")

If you want to access a value that coincides with a Swift-defined property, use a String subscript instead:

json.office.map     // Error: Maps to Sequence.map
json.office["map"]  // RBBJSON.string("https://maps.apple.com/?q=IL1")

To unbox a JSON value, use one of the failable initializers:

String(json.firstName) // "John"
String(json.lastName)  // "Appleseed"
String(json.age)       // nil

Int(json.age)          // 26
Double(json.age)       // 26.0

You can also make use of a JSONPath-inspired Query syntax to find nested data inside a JSON structure.

For example, given:

{ 
  "store": {
    "book": [ 
      { 
        "category": "reference",
        "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95
      },
      { 
        "category": "fiction",
        "author": "Evelyn Waugh",
        "title": "Sword of Honour",
        "price": 12.99
      },
      { 
        "category": "fiction",
        "author": "Herman Melville",
        "title": "Moby Dick",
        "isbn": "0-553-21311-3",
        "price": 8.99
      },
      { 
        "category": "fiction",
        "author": "J. R. R. Tolkien",
        "title": "The Lord of the Rings",
        "isbn": "0-395-19395-8",
        "price": 22.99
      }
    ],
    "bicycle": {
      "color": "red",
      "price": 19.95
    }
  }
}
JSONPath RBBJSON Result
$.store.book[*].author json.store.book[any: .child].author The authors of all books in the store.
$..author json[any: .descendantOrSelf].author All authors.
$.store.* json.store[any: .child] All things in the store, a list of books an a red bycicle.
$.store..price json.store[any: .descendantOrSelf].price All prices in the store.
$..book[2] json[any: .descendantOrSelf].book[2] The second book.
$..book[-2] json[any: .descendantOrSelf].book[-2] The second-to-last book.
$..book[0,1], $..book[:2] json[any: .descendantOrSelf].book[0, 1]), json[any: .descendantOrSelf].book[0...1]), json[any: .descendantOrSelf].book[0..<2]) The first two books.
$..book[?(@.isbn)] json[any: .descendantOrSelf].book[has: \.isbn] All books with an ISBN number.
$..book[?(@.price<10)] json.store.book[matches: { $0.price <= 10 }] All books cheaper than 10.
$.store["book", "bicycle"]..["price", "author"] json.store["book", "bicycle"][any: .descendantOrSelf]["price", "author"] The author (where available) and price of every book or bicycle.

Once you query a JSON value using one of the higher order selectors, the resulting type of the expression will be a lazy RBBJSONQuery:

json.store.book[0]["title"]     // RBBJSON.string("Sayings of the Century")
json.store.book[0, 1]["title"]  // some RBBJSONQuery

Because RBBJSONQuery conforms to Sequence, you can initialize an Array with it to obtain the results or use e.g. compactMap:

String(json.store.book[0].title)                    // "Sayings of the Century"
json.store.book[0, 1].title.compactMap(String.init) // ["Sayings of the Century", "Sword of Honour"]

String(json.store.book[0]["invalid Property"])                    // nil
json.store.book[0, 1]["invalid Property"].compactMap(String.init) // []

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].