patch open map state in json builder
This commit is contained in:
parent
00b72d0ddd
commit
87628fe3e2
2 changed files with 10 additions and 0 deletions
|
@ -156,6 +156,10 @@ public class JsonBuilder {
|
||||||
return appendable.toString();
|
return appendable.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void patchOpenMapState() {
|
||||||
|
state.first = false;
|
||||||
|
}
|
||||||
|
|
||||||
private void beginKey(String k) throws IOException {
|
private void beginKey(String k) throws IOException {
|
||||||
if (state.first) {
|
if (state.first) {
|
||||||
state.first = false;
|
state.first = false;
|
||||||
|
|
|
@ -312,6 +312,8 @@ public class MarcJsonWriter extends MarcContentHandler implements Flushable, Clo
|
||||||
/**
|
/**
|
||||||
* Write MARC record using fields, indicators, and subfield structures,
|
* Write MARC record using fields, indicators, and subfield structures,
|
||||||
* therefore allowing duplicate keys in the output.
|
* therefore allowing duplicate keys in the output.
|
||||||
|
* Duplicate keys are rejected by Elasticsearch.
|
||||||
|
*
|
||||||
* @param marcRecord the MARC record
|
* @param marcRecord the MARC record
|
||||||
* @throws IOException if writing fails
|
* @throws IOException if writing fails
|
||||||
*/
|
*/
|
||||||
|
@ -371,6 +373,8 @@ public class MarcJsonWriter extends MarcContentHandler implements Flushable, Clo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write MARC record from underlying map as key-oriented JSON. Use repeat maps to create lists.
|
* Write MARC record from underlying map as key-oriented JSON. Use repeat maps to create lists.
|
||||||
|
* Because no duplicate keyes are generated, this is the variant for Elasticsearch.
|
||||||
|
*
|
||||||
* @param marcRecord the MARC record
|
* @param marcRecord the MARC record
|
||||||
* @throws IOException if writing fails
|
* @throws IOException if writing fails
|
||||||
*/
|
*/
|
||||||
|
@ -521,6 +525,8 @@ public class MarcJsonWriter extends MarcContentHandler implements Flushable, Clo
|
||||||
}
|
}
|
||||||
if (!style.contains(Style.EMBEDDED_RECORD)) {
|
if (!style.contains(Style.EMBEDDED_RECORD)) {
|
||||||
sb.append('}');
|
sb.append('}');
|
||||||
|
} else {
|
||||||
|
jsonBuilder.patchOpenMapState();
|
||||||
}
|
}
|
||||||
writer.write(sb.toString());
|
writer.write(sb.toString());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue