protobuf-generic

Generic protobuf manipulation

License

License

Categories

Categories

Protobuf Data Data Structures
GroupId

GroupId

me.lyh
ArtifactId

ArtifactId

protobuf-generic_2.11
Last Version

Last Version

0.2.8
Release Date

Release Date

Type

Type

jar
Description

Description

protobuf-generic
Generic protobuf manipulation
Project URL

Project URL

https://github.com/nevillelyh/protobuf-generic
Project Organization

Project Organization

me.lyh
Source Code Management

Source Code Management

https://github.com/nevillelyh/protobuf-generic.git

Download protobuf-generic_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/me.lyh/protobuf-generic_2.11/ -->
<dependency>
    <groupId>me.lyh</groupId>
    <artifactId>protobuf-generic_2.11</artifactId>
    <version>0.2.8</version>
</dependency>
// https://jarcasting.com/artifacts/me.lyh/protobuf-generic_2.11/
implementation 'me.lyh:protobuf-generic_2.11:0.2.8'
// https://jarcasting.com/artifacts/me.lyh/protobuf-generic_2.11/
implementation ("me.lyh:protobuf-generic_2.11:0.2.8")
'me.lyh:protobuf-generic_2.11:jar:0.2.8'
<dependency org="me.lyh" name="protobuf-generic_2.11" rev="0.2.8">
  <artifact name="protobuf-generic_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='me.lyh', module='protobuf-generic_2.11', version='0.2.8')
)
libraryDependencies += "me.lyh" % "protobuf-generic_2.11" % "0.2.8"
[me.lyh/protobuf-generic_2.11 "0.2.8"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
com.fasterxml.jackson.module : jackson-module-scala_2.11 jar 2.10.1

provided (2)

Group / Artifact Type Version
com.google.protobuf : protobuf-java jar 3.11.1
com.google.code.findbugs : jsr305 jar 3.0.2

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.11 jar 3.1.0

Project Modules

There are no modules declared in this project.

protobuf-generic

Build Status codecov.io GitHub license Maven Central Scala Steward badge

Manipulate Protocol Buffers schemas and records in a generic manner without compiled classes, similar to Avro's GenericRecord.

Usage

import me.lyh.protobuf.generic._

val schema1 = Schema.of[MyRecord]  // generic representation of the protobuf schema
val jsonString = schema1.toJson  // serialize to JSON
val schema2 = Schema.fromJson(jsonString)  // deserialize from JSON

// read protobuf binary without original class
val bytes1: Array[Byte] = // binary MyRecord
val reader = GenericReader.of(schema2)
val record1 = reader.read(bytes1)  // generic record, i.e. Map[String, Any]
val jsonRecord = record1.toJson  // JSON string

// write protobuf binary without orignal class
val record2 = GenericRecord.fromJson(jsonRecord)  // generic record, i.e. Map[String, Any]
val writer = GenericWriter.of(schema2)
val bytes2 = writer.write(record2)  // binary MyRecord

License

Copyright 2016 Neville Li.

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

Versions

Version
0.2.8
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.1
0.1.0