mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-28 23:28:55 +00:00
#502 - jsonContext.toJson(o, generator, path) can not apply path on @Transient field that is an entity bean
This commit is contained in:
1 parent
e2666f0c4c
commit
9665de2dbe
7 files changed
+188
-3
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package com.avaje.tests.json.transientproperties;
|
||||
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.text.PathProperties;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.assertj.core.api.StrictAssertions.assertThat;
|
||||
|
||||
public class TestModelAJson {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
ModelA a = new ModelA();
|
||||
a.setId(1);
|
||||
a.setA("a");
|
||||
|
||||
ModelB b = new ModelB();
|
||||
b.setOneField(1);
|
||||
b.setTwoField(1);
|
||||
|
||||
a.setList(new ArrayList<ModelB>());
|
||||
a.getList().add(b);
|
||||
|
||||
PathProperties pathProperties = PathProperties.parse("(a,list(oneField))");
|
||||
|
||||
String json = Ebean.json().toJson(a, pathProperties);
|
||||
|
||||
assertThat(json).isEqualTo("{\"a\":\"a\",\"list\":[{\"oneField\":1}]}");
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user