def build_publication_bibtex(publication):
    """
    Build a bibtex entry from a JSON of structure
    {...  "fieldname":"fieldentry" ...} where special fieldnames "bibtype" and
    "bibid" form the bibtex id and bibtex type
    """
    bib_id = publication["bibid"]
    bib_type = publication["bibtype"]
    bibtex = '@{}{{{}\n'.format(bib_id, bib_type)
    del publication["bibid"]
    del publication["bibtype"]

    for field_name in publication:
        field_entry = publication[field_name]
        bibtex += "{}  =  {{{}}},\n".format(field_name, field_entry)

    bibtex += '}\n\n'
    return bibtex