Git Product home page Git Product logo

scala-json's Introduction

scala-json Known Vulnerabilities

import json._

@accessor case class Book(name: String, pages: Int, chapters: Seq[String])

Book("Making JSON Easy in Scala", 2, List("Getting Started, Fast", "Getting Back to Work")).js

res0: json.JObject =
{
  "name": "Making JSON Easy in Scala",
  "pages": 2,
  "chapters": ["Getting Started, Fast", "Getting Back to Work"]
}

Features

Compile time JSON marshalling of primitive values, case-classes, basic collections, and whatever you can imagine for scala, scala-native and scala-js.

  • Extensible accessor API. Serialize any type you want.
  • Provides a useful JS-like AST for intermediate JSON data.
  • Implicit accessors that chain to resolve Higher-Kind types (e.g. Option[T]).
  • Uses default fields correctly.
  • Preserves object field order.
  • Rich field exceptions with field names (all field errors, not just the first), perfect for form validation.
  • Ability to use non-string key types in a Map (for key types that serialize to JString).
  • Enables use of normal looking scala structures with any previously existing JSON API.
  • Produces pretty and human readable JSON from normal scala types.
  • Supports scala-js so you can extend your models to the web.
  • Supports scala-native so you can take your models everywhere else (requires jansson, available through apt, brew, etc).
  • Enables you to create readable APIs that match existing/specific class structure.
  • Exposes rich compile-time type info, more run-time type data than reflect could ever provide.
  • Uses existing scala collection CanBuildFrom factories to support buildable collections.
  • Provides support for unknown types (Any) via 'pickling' with a run-time class registry.
  • Support for scala 2.10.x, 2.11.x, 2.12.0-M3.
  • Support for scala-js 0.6.x.
  • Support for scala-native 0.1.x.

Docs

  • Usage and Examples - Getting started with basic usage and examples.
  • Accessors - Accessors are the compile-time constructs that allow you to go from a JValue to a scala type and back.
  • Registry - The Accessor Registry allows you to pickle registered types from untyped (Any) data.
  • Enumerator - Allows enumerated case object values of a sealed trait (useful for map keys).
  • EpochDeadline - Clone of scala's Deadline that serializes to numeric Unix epoch time.
  • Migration - Uses a version field in JSON to transform old schemas to new ones.
  • Scaladocs

SBT

resolvers += "mmreleases" at "https://artifactory.mediamath.com/artifactory/libs-release-global"

//scala
libraryDependencies += "com.mediamath" %% "scala-json" % "1.1"

//or scala + scala-js/scala-native
libraryDependencies += "com.mediamath" %%% "scala-json" % "1.1"

//for @accessor annotation support
resolvers += Resolver.sonatypeRepo("releases")
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)

Dependencies

  • macro-paradise 2.1.0+ required for @accessor annotation
  • jackson for JVM JSON string parsing
  • jansson for Scala Native JSON string parsing
  • re2 for fast and safe RegEx
  • µTest for testing
  • tut for doc building

scala-json's People

Contributors

colinrgodsey avatar ademartini avatar zajko avatar pswaminathan avatar

Watchers

 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.