Skip to content

Commit 973732a

Browse files
author
杨利兵
committed
解决msg/json group导出且内容为空的导致JSON格式不正确问题
1 parent fa76b3e commit 973732a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/com/yanglb/utilitys/codegen/core/translator/impl/MsgJsonTranslatorImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ protected void onTranslate() throws CodeGenException {
5252
StringBuilder sb = this.writableModel.getData();
5353
sb.append("{\r\n");
5454

55+
boolean hasDot = false;
56+
5557
// 分组输出
5658
if(this.paramaModel.getOptions().get("group") != null) {
5759
for(TableModel tblModel : this.model) {
@@ -66,16 +68,18 @@ protected void onTranslate() throws CodeGenException {
6668
sb.append(String.format(" \"%\"s: \"%s\",\r\n", id, value));
6769
}
6870
} else {
71+
hasDot = false;
6972
sb.append(String.format(" \"%s\": {\r\n", tblModel.getSheetName()));
7073
for(Map<String, String> itm : tblModel.toList()) {
7174
String id = itm.get("id");
7275
if(StringUtility.isNullOrEmpty(id)) continue;
7376
// 对字符串进行转换
7477
String value = this.convert2JsCode(itm.get(this.msgLang));
7578
sb.append(String.format(" \"%s\": \"%s\",\r\n", id, value));
79+
hasDot = true;
7680
}
7781
int idx = sb.lastIndexOf(",");
78-
if(idx != -1) {
82+
if(idx != -1 && hasDot) {
7983
sb.deleteCharAt(idx);
8084
}
8185

0 commit comments

Comments
 (0)