phenopackets / phenopacket-tools

An app and library for building, conversion, and validation of GA4GH Phenopackets.
http://phenopackets.org/phenopacket-tools/stable/
GNU General Public License v3.0
12 stars 5 forks source link

input of phenopacket message from string not working #87

Closed pnrobinson closed 2 years ago

pnrobinson commented 2 years ago

We are getting a String version of the phenopacket that appears correct, but the ingest to Message is not working. Here is a short version

public Message fromString(String msg) throws PhenopacketValidatorInputException {
        try {
            Phenopacket.Builder builder = Phenopacket.newBuilder();
            TextFormat.Parser parser = TextFormat.Parser.newBuilder().build();
            parser.merge(msg, builder);
            return builder.build();
        } catch (TextFormat.ParseException e ) {
            throw new PhenopacketValidatorInputException("Could not decode Message: " + e.getMessage());
        }
    }

But we get

Could not decode Message: Expected identifier. Found '{'

Not that we have com.google.protobuf.TextFormat and version 2 Phenopacket in this code

pnrobinson commented 2 years ago

Fixed, this should have been

Phenopacket.Builder builder = Phenopacket.newBuilder();
JsonFormat.parser().merge(jsonString, builder);
message = builder.build();