2017-03-10 2 views
0

私はAzure Storage(Table)のデータを持っており、そのデータを取得してAPIをスローするようにシリアル化しています。クラスのコレクションでJava(Androidスタジオ) ? APIを与えるAzureTableから取り出すJsonとしてのエンティティの解析

public class Book { 
String name; 
String author; 
String description; 

public Book(){} 

public Book(String name, String author, String description) { 
    this.name = name; 
    this.author = author; 
    this.description = description; 
    } 
} 

JSON:

"{\"operations\":[{\"title\":\"1984\",\"author\":\"Oruel\",\"description\":\"Antiutopy\",\"PartitionKey\":\"Books\",\"RowKey\":\"\",\"Timestamp\":\"2017-03-10T19:23:49.6668457+00:00\",\"ETag\":\"W/\\\"datetime'2017-03-10T19%3A23%3A49.6668457Z'\\\"\"},{\"title\":\"hello\",\"author\":\"world\",\"description\":\"test\",\"PartitionKey\":\"Books\",\"RowKey\":\"32de9806-617a-4b66-9a87-bd3488e9080e\",\"Timestamp\":\"2017-03-08T12:32:45.2881957+00:00\",\"ETag\":\"W/\\\"datetime'2017-03-08T12%3A32%3A45.2881957Z'\\\"\"}]}" 

答えて

0

をあなたがAzureテーブルストレージからデータを取得したいようだとAndroid上でJavaを使用しました。

簡単な方法は、以下のようにTableServiceEntityを継承し、あなたのBookクラスを書き換える経由Azure Storage SDK for Androidを使用しては、これらの操作を行うために公式tutorialを参照してくださいということです。詳細については、Azure Storage Android SDKのjavadocsをご覧ください。

public class Book extends TableServiceEntity { 
    String name; 
    String author; 
    String description; 

    public Book(){} 

    public Book(String sn, String name, String author, String description) { 
     this.partitionKey = "Books"; 
     this.rowKey = sn; 
     this.name = name; 
     this.author = author; 
     this.description = description; 
    } 

    // Setter & Getter methods for properties 
    .............. 
} 

あなただけ&がJSONとPOJOエンティティとの間でデータをデシリアライズシリアライズする必要がある場合は、それを行うにはGsonライブラリを使用してください。

関連する問題