Skip to content

Commit

Permalink
去掉多余的空格
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangYuanSheng1217 committed Jul 27, 2020
1 parent 6cf03e5 commit f364f64
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/com/github/restful/tool/utils/JsonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
*/
package com.github.restful.tool.utils;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.util.Map;

/**
Expand Down Expand Up @@ -74,6 +76,30 @@ private CustomPrettyPrinter() {
public DefaultPrettyPrinter createInstance() {
return this;
}

@Override
public void writeEndObject(JsonGenerator g, int nrOfEntries) throws IOException {
if (!_objectIndenter.isInline()) {
--_nesting;
}
if (nrOfEntries > 0) {
_objectIndenter.writeIndentation(g, _nesting);
}
/* else { g.writeRaw(' '); } */
g.writeRaw('}');
}

@Override
public void writeEndArray(JsonGenerator g, int nrOfValues) throws IOException {
if (!_arrayIndenter.isInline()) {
--_nesting;
}
if (nrOfValues > 0) {
_arrayIndenter.writeIndentation(g, _nesting);
}
/* else { g.writeRaw(' '); } */
g.writeRaw(']');
}
}
}
}

0 comments on commit f364f64

Please sign in to comment.