无法在Android中将Json数组转换为Json Object?

时间:2018-07-04 15:10:57

标签: php android json

Android中的getAppData方法给了我一个黑屏,但是如果我不将其转换为Json Object,它就会给我一个;

pipeline.apply(TextIO.read().from("gs://***/sampleBigtable.csv"))
    .apply(JdbcIO.write()
    .withDataSourceConfiguration(DataSourceConfiguration
    .create("org.postgresql.Driver", "jdbc:postgresql://***:5432/test")
    .withUsername("**").withPassword("password10"))
    .withStatement("insert into person values(?,?)")
    .withPreparedStatementSetter(
 new JdbcIO.PreparedStatementSetter < Object > () {
  /**
   * 
   */
  private static final long serialVersionUID = 1 L;

  @Override
  public void setParameters(Object arg0, PreparedStatement query)
  throws Exception {
   // TODO Auto-generated method stub
   query.setString(1, "Hello");
   query.setString(1, "Hi");
  }
 }));

但是我希望输出不带引号和方括号,如何实现呢?

PHP

["x.apk","xx.apk","xxx.apk"]

输出

$fileList = glob('xxxx/xxx/appstore_php/*');
   $files = [];
   foreach($fileList as $filename)
   {
      if ( is_file ( $filename ) )
      {
         $bname = basename ( $filename);
         $files[] = $bname;  
      }
   }

   header('Content-Type: application/json');
   $response = ["files" => $files];
   echo json_encode($response);

Android

   {"files":["x.apk","xx.apk","xxx.apk"]}

1 个答案:

答案 0 :(得分:1)

尝试:

for (int i = 0; i < jsonArr.length(); i++) {
   appList.add( jsonArr.getString(i) );
}