Hello .how to parse custome object this code:
Backendless.Persistence.describe( "Person", new AsyncCallback<List<ObjectProperty>>({
public void handleResponse( List<ObjectProperty> tableProperties )
{
Iterator<ObjectProperty> iterator = tableProperties;
while( iterator.hasMore() )
{
ObjectProperty propDef = iterator.next();
Log.i( "MYAPP", "property name - " + propDef.getName() );
Log.i( "MYAPP", "\tis property required - " + propDef.isRequired() );
Log.i( "MYAPP", "\tproperty data type - " + propDef.getType() );
Log.i( "MYAPP", "\tdefault value - " + propDef.getDefaultValue() );
Log.i( "MYAPP", "\tis property identity - " + propDef.getPrimaryKey() );
}
}
public void handleFault( BackendlessFault backendlessFault )
{
}
} );
my table columns are custom names.how to get the value that is in columns?
this api you use - returns a list of table columns, is it what you looking for?
no.i want to get columns values
in this case use “find” api instead of “describe”
here is an example https://backendless.com/docs/android/data_basic_search.html#example
Regards, Vlad
that’s ok.but in this API datas are retrieving to form of List<Map<,> but because I used android dataBinding, i should used dataModel class in an XML file that recyclerView adapter read datas from an XML file.
for example, this is my XML file:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.view.View"/>
<variable name="model" type="com.forodja.app.datas.model.Test"/>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:orientation="vertical">
<ImageView
android:id="@+id/img"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:adjustViewBounds="true"
app:image="@{model.thumbnail}"
tools:srcCompat="@drawable/google_pay"
tools:ignore="MissingConstraints"/>
<TextView
android:id="@+id/txtContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:padding="4dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txtTitle"
android:fontFamily="@font/normal_font"
android:maxLength="400"
android:ellipsize="end"
android:maxLines="6"
android:minLines="1"
android:textSize="16sp"
android:textColor="@color/md_grey_500"
android:text="@{model.content}"/>
<TextView
android:id="@+id/txtTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:padding="4dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/img"
android:maxLength="100"
android:maxLines="2"
android:minLines="1"
android:textSize="18sp"
android:fontFamily="@font/bold_font"
android:textColor="@color/md_black_1000"
android:text="@{model.title}"/>
</androidx.constraintlayout.widget.ConstraintLayout>
I should in below line describe data model class name:
<variable name="model" type="com.forodja.app.datas.model.Test"/>
but in find api, I down have any data model class and I have alone Map<,>
Hi @saeed_noshadi
Please read the documentation carefully. I recommend to learn the Data Service API section.
Especially Data Object and Basic Object Retrieval
For the Android and Java applications, there are two ways to represent data objects on the client side:
- Data objects can be stored/retrieved as instances of
java.util.Map
.
- Data objects can be represented as instances of custom classes mapped to data tables.
You can retrieve the data objects as instances of java.util.Map
or as instances of custom classes.
There are two tabs in code blocks: “Using Java Map” and "Custom class’.
If you want to use custom class, switch the tab to “Custom class” and look at the example.
And again, take a look at this link:
https://backendless.com/docs/android/data_basic_search.html#example
For your case you should use
Backendless.Data.of( Test.class ).find();
You will receive List<Test> testObjects
as a result.
Best Regards,
Maksym
now i get object response but i cant attach to recyclerView .i tought rsponse is not json object or json array and response is Map.how can i convert map response to Json?
This question is really outside of Backendless support. Try googling it or ask on stackoverflow.
Regards,
Mark