pattern


License

License

GroupId

GroupId

io.circe
ArtifactId

ArtifactId

circe-pattern_sjs0.6_2.12
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

pattern
pattern
Project URL

Project URL

https://github.com/circe/circe-droste
Project Organization

Project Organization

io.circe
Source Code Management

Source Code Management

https://github.com/circe/circe-droste

Download circe-pattern_sjs0.6_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/io.circe/circe-pattern_sjs0.6_2.12/ -->
<dependency>
    <groupId>io.circe</groupId>
    <artifactId>circe-pattern_sjs0.6_2.12</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.circe/circe-pattern_sjs0.6_2.12/
implementation 'io.circe:circe-pattern_sjs0.6_2.12:0.2.0'
// https://jarcasting.com/artifacts/io.circe/circe-pattern_sjs0.6_2.12/
implementation ("io.circe:circe-pattern_sjs0.6_2.12:0.2.0")
'io.circe:circe-pattern_sjs0.6_2.12:jar:0.2.0'
<dependency org="io.circe" name="circe-pattern_sjs0.6_2.12" rev="0.2.0">
  <artifact name="circe-pattern_sjs0.6_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.circe', module='circe-pattern_sjs0.6_2.12', version='0.2.0')
)
libraryDependencies += "io.circe" % "circe-pattern_sjs0.6_2.12" % "0.2.0"
[io.circe/circe-pattern_sjs0.6_2.12 "0.2.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.10
org.scala-js : scalajs-library_2.12 jar 0.6.32
io.circe : circe-core_sjs0.6_2.12 jar 0.13.0

test (6)

Group / Artifact Type Version
org.scala-js : scalajs-test-bridge_2.12 jar 0.6.32
io.circe : circe-generic_sjs0.6_2.12 jar 0.13.0
io.circe : circe-testing_sjs0.6_2.12 jar 0.13.0
org.scalacheck : scalacheck_sjs0.6_2.12 jar 1.14.3
org.scalatestplus : scalacheck-1-14_sjs0.6_2.12 jar 3.1.0.1
org.typelevel : discipline-scalatest_sjs0.6_2.12 jar 1.0.0

Project Modules

There are no modules declared in this project.

circe-droste

Build status Coverage status Gitter Maven Central

This project includes some tools for working with Circe's representation of JSON documents using recursion schemes. It currently includes a pattern functor for io.circe.Json and some basic integration with Droste.

Usage

Count all the nulls anywhere in a document!

import higherkindness.droste.Algebra, higherkindness.droste.scheme.cata
import io.circe.pattern.JsonF, io.circe.droste._, io.circe.literal._

val nullCounter: Algebra[JsonF, Int] = Algebra {
  case JsonF.NullF => 1
  case JsonF.ArrayF(xs) => xs.sum
  case JsonF.ObjectF(fs) => fs.map(_._2).sum
  case _ => 0
}

val doc = json"""{"x":[null,{"y":[1,null,true,[null,null]]}]}"""

val result = cata(nullCounter).apply(doc) // result: Int = 4

Or you can use Droste's foldMap:

import cats.instances.int._
import higherkindness.droste.syntax.project._
import io.circe.droste._, io.circe.literal._

val doc = json"""{"x":[null,{"y":[1,null,true,[null,null]]}]}"""

val result = doc.foldMap(j => if (j.isNull) 1 else 0) // result: Int = 4

Contributors and participation

This project supports the Scala code of conduct and we want all of its channels (Gitter, GitHub, etc.) to be welcoming environments for everyone.

Please see the Circe contributors' guide for details on how to submit a pull request.

License

circe-droste is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

io.circe

circe

Versions

Version
0.2.0
0.1.0