phenopackets/phenopacket-tools

input of phenopacket message from string not working

pnrobinson opened this issue · 1 comments

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

Fixed, this should have been

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