<commit_before>
= Introduction

This gem extends the *ruby_protobuf* [1] gem to allow two new encodings in
a protocol buffer message:

- <tt>JSON</tt>
- <tt>INDEXED</tt>

= Installation

    gem install protojson

= How to use

== Serialize a message

    require 'addressbook.pb'
    require 'protojson'
    person = Tutorial::Person.new
    person.parse_from_file ARGV[0]

    Protobuf::Message::encoding = Protobuf::Message::EncodingType::INDEXED

    value = person.serialize_to_string

    puts value




[1] ruby_protobuf: https://github.com/macks/ruby-protobuf<commit_msg>README changed<commit_after>
# Introduction

This gem extends the *ruby_protobuf* [1] gem to allow two new encodings in
a protocol buffer message:

- <tt>JSON</tt>
- <tt>INDEXED</tt>

[1] ruby_protobuf: https://github.com/macks/ruby-protobuf

# Installation

    gem install protojson

# How to use

## Serialize a message

    require 'addressbook.pb'
    require 'protojson'
    person = Tutorial::Person.new
    person.parse_from_file ARGV[0]

    Protobuf::Message::encoding = Protobuf::Message::EncodingType::INDEXED

    value = person.serialize_to_string

    puts value

## Parse a message

#!/usr/bin/env ruby

    require 'addressbook.pb'
    require 'protojson'

    person = Tutorial::Person.new
    person.parse_from_file ARGV[0]

    Protobuf::Message::encoding = Protobuf::Message::EncodingType::INDEXED

    value = person.serialize_to_string

    person = Tutorial::Person.new

    person.parse_from_string(value)

    p person

{'fraction_non_alphanumeric': 0.10433070866141732, 'fraction_numerical': 0.004593175853018373, 'mean_word_length': 3.8722044728434506, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '549794', 'n_tokens_mistral': 511, 'n_tokens_neox': 475, 'n_words': 118}