Skip to content

Commit f545c4e

Browse files
committed
fix issue with rendering JSON result with propspec in regex
1 parent 024907b commit f545c4e

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/main/java/act/cli/view/CliView.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private void buildTree(StringBuilder sb, TreeNode node, String prefix, boolean i
124124
JSON () {
125125
@Override
126126
public String render(Object result, PropertySpec.MetaInfo filter, ActContext context) {
127-
return render(result, filter, context, true);
127+
return render(result, filter, context, context instanceof CliContext);
128128
}
129129

130130
public String render(Object result, PropertySpec.MetaInfo filter, ActContext context, boolean format) {
@@ -141,9 +141,17 @@ public String render(Object result, PropertySpec.MetaInfo filter, ActContext con
141141
} else {
142142
// output fields only applied when excluded fields not presented
143143
propertyFilter.addIncludes(outputs);
144+
if (FastJsonPropertyPreFilter.hasPattern(outputs)) {
145+
// TODO: handle the case when result is an Iterable
146+
propertyFilter.setFullPaths(context.app().service(DataPropertyRepository.class).propertyListOf(result.getClass()));
147+
}
144148
}
145149
} else {
146150
propertyFilter.addExcludes(excluded);
151+
if (FastJsonPropertyPreFilter.hasPattern(excluded)) {
152+
// TODO: handle the case when result is an Iterable
153+
propertyFilter.setFullPaths(context.app().service(DataPropertyRepository.class).propertyListOf(result.getClass()));
154+
}
147155
}
148156

149157
MappedFastJsonNameFilter nameFilter = new MappedFastJsonNameFilter(filter.labelMapping());

src/main/java/act/util/FastJsonPropertyPreFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private boolean matches(Set<String> paths, String path, boolean exclude) {
163163
return false;
164164
}
165165

166-
private boolean hasPattern(Set<String> paths) {
166+
public static boolean hasPattern(Collection<String> paths) {
167167
return S.join("", paths).contains("*");
168168
}
169169

0 commit comments

Comments
 (0)