# protobuf-to-data-classes

> Convert protobuf to data classes

Latest version **0.0.1** (published 2022-03-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install protobuf-to-data-classes
pnpm add protobuf-to-data-classes
yarn add protobuf-to-data-classes
bun add protobuf-to-data-classes
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2022-03-31 |
| First published | 2022-03-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 41.3 KB |
| Known vulnerabilities | 0 (+11 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | mobile.admin.teko |

## Links

- npm: https://www.npmjs.com/package/protobuf-to-data-classes
- npm.io page: https://npm.io/package/protobuf-to-data-classes

## Dependencies (2)

- [protobufjs](https://npm.io/package/protobufjs.md) ~6.11.2
- [proto-parser](https://npm.io/package/proto-parser.md) ^0.0.8

## Recent versions

- 0.0.1 (latest) — 2022-03-31

## README

# proto-to-data-classes

A simple codegen tool for convert protobuf to corresponding data classes in some programming language to use with some JSON libraries (Gson, Codable).

## Table of Contents

- [Usage](#usage)
  - [Install](#install)
  - [Coding](#coding)
- [API](#api)
  - [parse](#parse)

## Usage

### Install

```
npm install protobuf-to-data-classes
```

or

```
yarn add protobuf-to-data-classes
```

### Coding

A code example:

```ts
import { convertProtobufToDataClasses, DataClassType } from 'protobuf-to-data-classes';

const content = `
syntax = 'proto3';
message Foo {
  string bar = 1;
}
`;

generatedCode = convertProtobufToDataClasses(content, DataClassType.KotlinGson);
console.log(generatedCode);
```

The resulted code:

```kotlin
import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName

data class Foo(
    @Expose
    @SerializedName("bar")
    val bar: String?,
)
```

## API

### `convertProtobufToDataClasses(protobuf: string, dataClassType: DataClassType): string

Generate corresponding data classes for the given protobuf content.

## TODO

- Support more options for data classes.
- Refactor code because the current code base is not good :].
- Create a simple web app.

---
_Source: https://npm.io/package/protobuf-to-data-classes · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
