How to go through a Gson object, with multiple levels Arrays - java

I'm trying to get the parameters inside jSon items>item>image>images>transparent using the Gson library. The idea is to capture transparent, transparent_blank and transparent_dark. But I don't know how I can get these values, for the moment I have created the following:
Json
{
"date_layout":"day-month-year",
"lastupdate":1547596830,
"items":[{
"name":"Cleans Cuts",
"featured":"true",
"item":{
"image":"http:www.domain.com/unwanted_image.jpg",
"images":{
"transparent":"http:www.domain.com/desired_image1.jpg",
"transparent_blank":"http:www.domain.com/desired_image2.jpg",
"transparent_dark":"http:www.domain.com/desired_image3.jpg"
}
}
},
{
"name":"Cleans Cuts",
"featured":"true",
"item":{
"image":"http:www.domain.com/unwanted_image.jpg",
"images":{
"transparent":"http:www.domain.com/desired_image1.jpg",
"transparent_blank":"http:www.domain.com/desired_image2.jpg",
"transparent_dark":"http:www.domain.com/desired_image3.jpg"
}
}
}]
}
.MainActivity
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String url = "http://www.example.com/file.json";
Request request = new Request.Builder()
.url(url)
.build();
Response response = client.newCall(request).execute();
if(response.isSuccessful()){
String response_jSon = response.body().string();
Gson gson = new Gson();
Datos datosFinal = gson.fromJson(response_jSon, Datos.class);
for (int i=0; i<datosFinal.items.size(); i++){
Log.d("msg_2", datosFinal.items.get(i).name);
}
}
And I'm only able to get to items as you can see in the .MainActivity Log.
Class Objects for the Json
Datos.java
public class Datos {
public String date_layout;
public Int lastupdate;
List<items> items;
}
items.java
public class items {
public String name;
}

The json is not very clean, I would suggest that you rework how this json string is generated, but if you still want to achieve getting those values without reworking the json, you need to change your Items class to :
`public class items {
public String name;
public String featured;
public Item item;
}`
Then you need to create another class called Item
`public class Item{
public String image;
public Image images;
}`
You will also need to create an Image class, like so:
`public class Image {
public String transparent;
public String transparent_blank;
public String transparent_dark;
}`
Then you can log these values in your loop:
`Datos datosFinal = gson.fromJson(response_jSon, Datos.class);
for (int i=0; i<datosFinal.items.size(); i++){
Log.d("msg_2", datosFinal.items.get(i).item.images.transparent);
Log.d("msg_2", datosFinal.items.get(i).item.images.transparent_blank);
Log.d("msg_2", datosFinal.items.get(i).item.images.transparent_dark);
}`
While this may work, I would highly suggest you to rework your json and make it easier to maintain.

You have to create the following class also to getting value for transparent, transparent_blank and transparent_dark
Images.java
Item.java
Replace this class:
public class Items{
private Item item;
private String name;
private String featured;
public Item getItem ()
{
return item;
}
public void setItem (Item item)
{
this.item = item;
}
public String getName ()
{
return name;
}
public void setName (String name)
{
this.name = name;
}
public String getFeatured ()
{
return featured;
}
public void setFeatured (String featured)
{
this.featured = featured;
}
}
Add this class:
public class Images{
private String transparent_blank;
private String transparent_dark;
private String transparent;
public String getTransparent_blank ()
{
return transparent_blank;
}
public void setTransparent_blank (String transparent_blank)
{
this.transparent_blank = transparent_blank;
}
public String getTransparent_dark ()
{
return transparent_dark;
}
public void setTransparent_dark (String transparent_dark)
{
this.transparent_dark = transparent_dark;
}
public String getTransparent ()
{
return transparent;
}
public void setTransparent (String transparent)
{
this.transparent = transparent;
}
}
Also, Add this Class:
public class Item {
private Images images;
private String image;
public Images getImages ()
{
return images;
}
public void setImages (Images images)
{
this.images = images;
}
public String getImage ()
{
return image;
}
public void setImage (String image)
{
this.image = image;
}
}
Now, you will get the value using the getter method.

you must use
public class items {
public String name;
#Expose(serialize = false, deserialize = false)
public String featured;
#Expose(serialize = false, deserialize = false)
public item mItem;
}
public class item {
#Expose(serialize = false, deserialize = false)
public String image;
#Expose(serialize = false, deserialize = false)
public images mImages;
}
public class images {
#Expose(serialize = false, deserialize = false)
public String transparent;
#Expose(serialize = false, deserialize = false)
public String transparent_blank;
#Expose(serialize = false, deserialize = false)
public String transparent_dark;
}
you can genetate pojo by using http://www.jsonschema2pojo.org/

Related

how to convert string into Json and extrat from it info

I'm using retrofit2 and Rxjava2 to insert/get information from mongodb and nodeJs server, for now, I receive all data as a string but I want to get hole collection Infos from my base so I need to convert string to JSON and get each information.
My code to receive data:
1- Service:
#POST("collect/get")
#FormUrlEncoded
Observable<String> getcollection(#Field("selector") String selector);
2-RetrofitClient:
if(instance == null){
instance = new Retrofit.Builder()
.baseUrl("http://transportor.ddns.net:3000/")
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(ScalarsConverterFactory.create()).build();
}
3- Recieve function
private void getallcollection(String selector) {
compositeDisposable.add(myServices.getcollection(selector)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<String>(){
#Override
public void accept(String s) throws Exception {
Log.d("infos",s);
}
}));
}
I'm already prepared Collection class:
public class col {
private String creator;
private String emailcol;
private String date_creation_col;
private String nom_col;
private String long_col;
private String lat_col;
private String tel_fix_col;
private String tel_mobile_col;
private String creatorcreator;
private String heure_matin_col;
private String heure_apresmatin_col;
private String type;
private String imagePath;
public col(String creator, String emailcol, String date_creation_col, String nom_col, String long_col, String lat_col, String tel_fix_col, String tel_mobile_col, String creatorcreator, String heure_matin_col, String heure_apresmatin_col, String type, String imagePath) {
this.creator = creator;
this.emailcol = emailcol;
this.date_creation_col = date_creation_col;
this.nom_col = nom_col;
this.long_col = long_col;
this.lat_col = lat_col;
this.tel_fix_col = tel_fix_col;
this.tel_mobile_col = tel_mobile_col;
this.creatorcreator = creatorcreator;
this.heure_matin_col = heure_matin_col;
this.heure_apresmatin_col = heure_apresmatin_col;
this.type = type;
this.imagePath = imagePath;
}
public String getCreator() {
return creator;
}
public void setCreator(String creator) {
this.creator = creator;
}
public String getEmailcol() {
return emailcol;
}
public void setEmailcol(String emailcol) {
this.emailcol = emailcol;
}
public String getDate_creation_col() {
return date_creation_col;
}
public void setDate_creation_col(String date_creation_col) {
this.date_creation_col = date_creation_col;
}
public String getNom_col() {
return nom_col;
}
public void setNom_col(String nom_col) {
this.nom_col = nom_col;
}
public String getLong_col() {
return long_col;
}
public void setLong_col(String long_col) {
this.long_col = long_col;
}
public String getLat_col() {
return lat_col;
}
public void setLat_col(String lat_col) {
this.lat_col = lat_col;
}
public String getTel_fix_col() {
return tel_fix_col;
}
public void setTel_fix_col(String tel_fix_col) {
this.tel_fix_col = tel_fix_col;
}
public String getTel_mobile_col() {
return tel_mobile_col;
}
public void setTel_mobile_col(String tel_mobile_col) {
this.tel_mobile_col = tel_mobile_col;
}
public String getCreatorcreator() {
return creatorcreator;
}
public void setCreatorcreator(String creatorcreator) {
this.creatorcreator = creatorcreator;
}
public String getHeure_matin_col() {
return heure_matin_col;
}
public void setHeure_matin_col(String heure_matin_col) {
this.heure_matin_col = heure_matin_col;
}
public String getHeure_apresmatin_col() {
return heure_apresmatin_col;
}
public void setHeure_apresmatin_col(String heure_apresmatin_col) {
this.heure_apresmatin_col = heure_apresmatin_col;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getImagePath() {
return imagePath;
}
public void setImagePath(String imagePath) {
this.imagePath = imagePath;
}
}
Actually I received all data and console show me : [{"_id":"5e22074673c926147c3a73f5","date_creation_col":"17-01-2020","creator":"Alaeddine","emailcol":"amir#gmail.com","nom_col":"amir","long_col":"10.179326869547367","lat_col":"36.83353893150942","tel_fix_col":"123","tel_mobile_col":"1234","adress_col":"rue Paris mision 34","heure_matin_col":"7","heure_apresmatin_col":"5","type":"collection","imagePath":"mmmmmmmmmmmm"}]
I want to know how to extract for example creator from this Json.
You can use a third-party JSON parser, like Google GSON, as you're already developing for Android. Java does not seem to contain a built-in JSON parser.
See this answer.

Android: Use result from stringrequest in individual textviews

I have been able to get a string from an url, using volley. This string is now shown as one block in a textview. But I would like to be able to display this data in individual textviews. How could I do this?
Maybe important to know: I'm completely new at programming and this is my first week I'm doing this. So my method I used could be strange, and this might be a stupid question, but I'm just trying to learn, and to get the result I want.
This is the code I have now, to get the data from the url:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.text);
queue = Volley.newRequestQueue(this);
StringRequest request = new StringRequest(Request.Method.GET, URL, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
textView.setText(response.toString());
Toast.makeText(MainActivity.this,response.toString(),Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Log.d("error",error.toString());
}
});
queue.add(request);
And this is how the result from the GET from the url looks like:
{"DeliveryDetailId":91003,"Delivery":{"DeliveryId":91,"DeliveryNumber":"1248","DropLocation":null,"DeliveryState":0},"ProductNumber":null,"Description":null,"PickLocation":"104","LocationCheck":null,"Quantity":64.0,"Histories":[],"BinNumberToUse":null}
So in this case I would like to have textviews which show the DeliveryID, Picklocation and Quantity. How can I extract this info from the string, so I can show it in the Textviews?
create model classes like below and store the response in Response.class
Then you can able to access DeliveryID by calling getDeliveryID()
-----------------------------------com.saranga.app.model.Delivery.java-----------------------------------
package com.saranga.app.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Delivery {
#SerializedName("DeliveryId")
#Expose
private Integer deliveryId;
#SerializedName("DeliveryNumber")
#Expose
private String deliveryNumber;
#SerializedName("DropLocation")
#Expose
private Object dropLocation;
#SerializedName("DeliveryState")
#Expose
private Integer deliveryState;
public Integer getDeliveryId() {
return deliveryId;
}
public void setDeliveryId(Integer deliveryId) {
this.deliveryId = deliveryId;
}
public String getDeliveryNumber() {
return deliveryNumber;
}
public void setDeliveryNumber(String deliveryNumber) {
this.deliveryNumber = deliveryNumber;
}
public Object getDropLocation() {
return dropLocation;
}
public void setDropLocation(Object dropLocation) {
this.dropLocation = dropLocation;
}
public Integer getDeliveryState() {
return deliveryState;
}
public void setDeliveryState(Integer deliveryState) {
this.deliveryState = deliveryState;
}
}
-----------------------------------com.saranga.app.model.Response.java-----------------------------------
package com.saranga.app.model;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Response {
#SerializedName("DeliveryDetailId")
#Expose
private Integer deliveryDetailId;
#SerializedName("Delivery")
#Expose
private Delivery delivery;
#SerializedName("ProductNumber")
#Expose
private Object productNumber;
#SerializedName("Description")
#Expose
private Object description;
#SerializedName("PickLocation")
#Expose
private String pickLocation;
#SerializedName("LocationCheck")
#Expose
private Object locationCheck;
#SerializedName("Quantity")
#Expose
private Double quantity;
#SerializedName("Histories")
#Expose
private List<Object> histories = null;
#SerializedName("BinNumberToUse")
#Expose
private Object binNumberToUse;
public Integer getDeliveryDetailId() {
return deliveryDetailId;
}
public void setDeliveryDetailId(Integer deliveryDetailId) {
this.deliveryDetailId = deliveryDetailId;
}
public Delivery getDelivery() {
return delivery;
}
public void setDelivery(Delivery delivery) {
this.delivery = delivery;
}
public Object getProductNumber() {
return productNumber;
}
public void setProductNumber(Object productNumber) {
this.productNumber = productNumber;
}
public Object getDescription() {
return description;
}
public void setDescription(Object description) {
this.description = description;
}
public String getPickLocation() {
return pickLocation;
}
public void setPickLocation(String pickLocation) {
this.pickLocation = pickLocation;
}
public Object getLocationCheck() {
return locationCheck;
}
public void setLocationCheck(Object locationCheck) {
this.locationCheck = locationCheck;
}
public Double getQuantity() {
return quantity;
}
public void setQuantity(Double quantity) {
this.quantity = quantity;
}
public List<Object> getHistories() {
return histories;
}
public void setHistories(List<Object> histories) {
this.histories = histories;
}
public Object getBinNumberToUse() {
return binNumberToUse;
}
public void setBinNumberToUse(Object binNumberToUse) {
this.binNumberToUse = binNumberToUse;
}
}
You need to decode your JSONObject and individually get each element unless it's in a JSONArray in that case you need to loop through it
#Override
public void onResponse(String response) {
JSONObject json = new JSONObject(response);
textView.setText(json.getString("DeliveryDetailld"));
JSONObject details = json.getJSONObject("Delivery");
//Get data in Delivery Object
textView2.setText(details.getString("DeliveryId"));
}

how to get Json objects from json array and use them with model class

I want to link my received json data to my pojo class using gson library.I used volley library to receive the data.What should i do so that whenever i call getter methods from my pojo class then i get the received json data.
My Json data is in this format.
{
"vichList":[ {
id=1,
username="abc....},
{....},
]
}
I want to get this json data into my pojo class.
Vich.java
public class GetfeedResponse {
private List<Vich> vichList;
public List<Vich> getVichList() {
return vichList;
}
public void setVichList(List<Vich> vichList) {
this.vichList = vichList;
}
}
Vich.java
public class Vich {
private int id;
private String username;
private String full_name;
private String createdAt;
private int vich_id;
private String vich_content;
private String city;
private int like_count;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFull_name() {
return full_name;
}
public void setFull_name(String full_name) {
this.full_name = full_name;
}
public String getCreatedAt() {
return createdAt;
}
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}
public int getVich_id() {
return vich_id;
}
public void setVich_id(int vich_id) {
this.vich_id = vich_id;
}
public String getVich_content() {
return vich_content;
}
public void setVich_content(String vich_content) {
this.vich_content = vich_content;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public int getLike_count() {
return like_count;
}
public void setLike_count(int like_count) {
this.like_count = like_count;
}
}
Here i am getting the json response using volley library.
httpUtil.getrequest(url,this,new VolleyCallback(){
#Override
public void onSuccess(String result){
GetfeedResponse getfeedResponse = new GetfeedResponse();
// for(Vich vich : getfeedResponse.getVichList()){
// }
Log.d("Response Result:",result);
}
How can i get objects from json array and use them with the help of pojo class?
Using Gson
Add the following dependency in your gradle:
implementation 'com.google.code.gson:gson:2.8.5'
In your onSuccess()
GetfeedResponse getfeedResponse=new Gson().fromJson(result, GetfeedResponse.class);
If you wish to use Volley and POJO its better to use custom GSON request. Check this link : Custom GSON request With Volley
GSON:
GetfeedResponse parsed = new Gson().fromJson(response, GetfeedResponse.class);
Jackson:
GetfeedResponse parsed = new ObjectMapper().readValue(response, GetfeedResponse.class);
Additionally, if you wanted to convert only list of Vich items (and you stripped your JSON accordingly) you could do following:
[ {
id=1,
username="abc....},
{....},
]
List<Vich> viches = Arrays.asList(new Gson().fromJson(vichItemsJson, Vich[].class));

Retrofit get object with empty fields

I use Retrofit 2.4 and try to get data from Asp.Net Core 2.0 WebApi Service.
Here Java class:
public class Category {
private int CategoryID;
private String Name;
private String Image;
public Category(){
Name="";
Image="";
}
public Category(int categoryID, String name, String image) {
Name = name;
Image = image;
CategoryID=categoryID;
}
public int getCategoryID() {return CategoryID;}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public String getImage() {
return Image;
}
public void setImage(String image) {
Image = image;
}
}
Here Retrofit code:
public class Common {
public static User CURRENT_USER;
public static String SERVER_NAME="http://ip_address:5000";
public static IApiService ApiService;
public Common()
{
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(SERVER_NAME)
.addConverterFactory(GsonConverterFactory.create())
.build();
ApiService = retrofit.create(IApiService.class);
}
}
public interface IApiService
{
#GET("api/Categories")
Call<List<Category>> GetCategoryColl();
}
And then i write server side via Asp.Net Core 2.0 WebApi.
I have a controller:
[Produces("application/json")]
[Route("api/Categories")]
public class CategoriesController : Controller
{
private readonly MovieAppServerContext _context;
public CategoriesController(MovieAppServerContext context)
{
_context = context;
}
// GET: api/Categories
[HttpGet]
public IEnumerable<Category> GetCategory()
{
return _context.Category;
}
// GET: api/Categories/5
[HttpGet("{id}")]
public async Task<IActionResult> GetCategory([FromRoute] int id)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
var category = await _context.Category.SingleOrDefaultAsync(m => m.CategoryID == id);
if (category == null)
{
return NotFound();
}
return Ok(category);
}
// PUT: api/Categories/5
[HttpPut("{id}")]
public async Task<IActionResult> PutCategory([FromRoute] int id, [FromBody] Category category)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
if (id != category.CategoryID)
{
return BadRequest();
}
_context.Entry(category).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!CategoryExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return NoContent();
}
// POST: api/Categories
[HttpPost]
public async Task<IActionResult> PostCategory([FromBody] Category category)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
_context.Category.Add(category);
//await _context.SaveChangesAsync();
_context.SaveChanges();
return Ok(category);
}
// DELETE: api/Categories/5
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteCategory([FromRoute] int id)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
var category = await _context.Category.SingleOrDefaultAsync(m => m.CategoryID == id);
if (category == null)
{
return NotFound();
}
_context.Category.Remove(category);
// await _context.SaveChangesAsync();
_context.SaveChanges();
return Ok("Removed!");
}
private bool CategoryExists(int id)
{
return _context.Category.Any(e => e.CategoryID == id);
}
}
Here server side class of Category:
public class Category
{
[Key]
public int CategoryID { get; set; }
public String Name { get; set; }
public String Image { get; set; }
public Category()
{
}
public Category(String name, String image)
{
Name = name;
Image = image;
}
}
So, i check server code via Swagger and it works well: i get all data from Categories List.
But, when i try to get data from Android code via Retrofit - i get collection with empty objects : all fields are null or empty (i think it is default values).
So, here the code:
public class Home extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
List<Category> _categoryList =new ArrayList<>();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
//some code
Common.ApiService.GetCategoryColl().enqueue(new Callback<List<Category>>() {
#Override
public void onResponse(Call<List<Category>> call, Response<List<Category>> response) {
Log.i("GetCategories",response.message());
_categoryList=response.body();
// !!!! HERE. _category list contains objects but all of them
// are empty!
}
#Override
public void onFailure(Call<List<Category>> call, Throwable t) {
Log.e("GetCategories",t.getMessage());
}
});
}
}
So, i do not know, why it happens? How to fix that?
Thank you!
You haven't added #SerializedName("json-key-name") to your fields in the Java Category class:
#SerializedName("categoryId")
private int CategoryID;
#SerializedName("name")
private String Name;
#SerializedName("image")
private String Image;
Now GSON can map JSON response to the POJO properly.
By default Gson expects the field names to be the same as the Json ones, if you want to change this behavior, you have two options:
1.Use a FieldNamingPolicy, for your case it would be UPPER_CAMEL_CASE, below a sample how to do it for Retrofit:
Gson gson = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
.create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(SERVER_NAME)
.addConverterFactory(GsonConverterFactory.create())
.build();
2. Use the SerializedName annotation on your java fields.

Jackson XML Parsing

Jackson 2.2.3
First, please excuse the stupid mistakes, I'm on a disconnected network, so I had to retype manually)
I have the following XML:
<orgs>
<org name="Test1">
<item>a</item>
<item>b</item>
</org>
<org name="Test2">
<item>c</item>
<item>d</item>
<item>e</item>
</org>
</orgs>
I have the following class to parse this:
#XmlRootElement(name = "orgs")
#XmlAccessorType(XmlAccessType.FIELD)
public class XmlOrgElements {
private List<Org> orgs;
public List<Org> getOrgs() {
return orgs;
}
public void setOrg(List<Org> orgs) {
this.orgs = orgs;
}
public class Org {
#JacksonXmlProperty(isAttribute = true)
private String name;
private List<Item> items;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Item> getItems() {
return items;
}
public void setName(List<Item> items) {
this.items = items;
}
}
public class Item {
#JacksonXmlText
private String item;
public String getItem() {
return item;
}
public void setItem(String item) {
this.item = item;
}
}
}
But all I'm getting back is "orgs=null". Does anyone know why?
You need to enable unwrapped handling for lists; default is to use "wrapped" format. The best way to diagnose this problem is to start with Java objects, serialize as XML, and see what the output format is.
This gives an idea of how structure differs.
If you want to default to unwrapped style, you can use:
JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
mapper.registerModule(module);
There is also an annotation #JacksonXmlElementWrapper:
public class Bean {
#JacksonXmlElementWrapper(useWrapping=false)
public List<Stuff> entry;
}
to change behavior on per-list-property basis.
Here is the answer for those reading along:
#JacksonXmlRootElement(localname = "orgs")
public class Orgs {
#JacksonXmlElementWrapper(useWrapping = false)
private List<Org> org;
public List<Org> getOrg() {
return org;
}
public void setOrg(List<Org> org) {
this.orgs = org;
}
public Orgs() {}
}
public class Org {
#JacksonXmlProperty(isAttribute = true)
private String name;
#JacksonXmlElementWrapper(useWrapping = false)
private List<String> item;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getItem() {
return item;
}
public void setItem(List<String> item) {
this.item = item;
}
}

Categories

Resources