### Question:
PartitionSpecParser { public static void toJson(PartitionSpec spec, JsonGenerator generator) throws IOException { generator.writeStartObject(); generator.writeNumberField(SPEC_ID, spec.specId()); generator.writeFieldName(FIELDS); toJsonFields(spec, generator); generator.writeEndObject(); } private  PartitionSpecParser(); static void toJson(PartitionSpec spec, JsonGenerator generator); static String toJson(PartitionSpec spec); static String toJson(PartitionSpec spec, boolean pretty); static PartitionSpec fromJson(Schema schema, JsonNode json); static PartitionSpec fromJson(Schema schema, String json);  }### Answer:
@Test public void testToJsonForV1Table() { String expected = "{\n" + " \"spec-id\" : 0,\n" + " \"fields\" : [ {\n" + " \"name\" : \"data_bucket\",\n" + " \"transform\" : \"bucket[16]\",\n" + " \"source-id\" : 2,\n" + " \"field-id\" : 1000\n" + " } ]\n" + "}"; Assert.assertEquals(expected, PartitionSpecParser.toJson(table.spec(), true)); PartitionSpec spec = PartitionSpec.builderFor(table.schema()) .bucket("id", 8) .bucket("data", 16) .build(); table.ops().commit(table.ops().current(), table.ops().current().updatePartitionSpec(spec)); expected = "{\n" + " \"spec-id\" : 1,\n" + " \"fields\" : [ {\n" + " \"name\" : \"id_bucket\",\n" + " \"transform\" : \"bucket[8]\",\n" + " \"source-id\" : 1,\n" + " \"field-id\" : 1000\n" + " }, {\n" + " \"name\" : \"data_bucket\",\n" + " \"transform\" : \"bucket[16]\",\n" + " \"source-id\" : 2,\n" + " \"field-id\" : 1001\n" + " } ]\n" + "}"; Assert.assertEquals(expected, PartitionSpecParser.toJson(table.spec(), true)); }