我想将其他(controller
)类的字符串添加到" JSON类"我创建了但我不知道我已经在这个类中添加了一些 string [] :
我是java的新手。你有解决我的问题的方法吗?
例如,我想在此JSON中用Table1
替换我的字符串:
public class JSON {
public String jsonfile;
public String JSONFilter(String[] point)throws IOException {
String count01="{\n" +
" \"tags\": {\n" +
" \"load_all\": true,\n" +
" \"exclude\": [\n" +
" \"created_by\",\n" +
" \"source\"\n" +
" ]\n" +
" },\n" +
" \"tables\": {\n" +
" \"Table1\": {\n" +
" \"fields\": [\n" +
" {\n" +
" \"type\": \"id\",\n" +
" \"name\": \"osm_id\"\n" +
" },\n" +
" {\n" +
" \"type\": \"geometry\",\n" +
" \"name\": \"geometry\"\n" +
" },\n" +
" {\n" +
" \"type\": \"hstore_tags\",\n" +
" \"name\": \"tags\"\n" +
" }\n" +
" ],\n" +
" \"type\":";
String count02 = "\"points\",\"mapping\":{";
String count03 = "\"amenity\":[";
for (int i=0; i<point.length; i++){
String b1 = "\""+point[i].toString()+"\",";
count03+=b1;
}
count03 = count03.replaceAll(",$", "");
String count04= count03+"]";
String count06= "}}}}";
String part_final=count01+count02+count04+count06;
System.out.println(part_final);
}
}