gen.setNextName(new QName("root"));
gen.writeStartObject();
// and also need to force attribute
gen.writeFieldName("attr");
gen.setNextIsAttribute(true);
gen.writeNumber(-3);
// Also let's add child element as well
gen.setNextIsAttribute(false);
gen.writeFieldName("elem");
gen.writeNumber(13);