Support Topics Documentation Slack YouTube Blog

JSON and Web Services


(Okwui Agada) #1

I am a newbie. Does Backendless have any core functions for handling json and web services or I can use third party libraries?


(Sergey Kukurudzyak) #2

All backendless services handling json. Please describe your use case and we will try to help you


(Okwui Agada) #3

I want to access 3rd party web service from my backendless service. It will require me to send json and also to receive json data. I will like to parse the json data.


(Sergey Kukurudzyak) #4

What language you would like to use for backendless service, JS or JAVA?


(Okwui Agada) #5

I am using Java to build my services.


(Sergey Kukurudzyak) #6

Please read the doc https://backendless.com/docs/bl-java/doc.html

for example you have a service:

package com.mbaas;
 
import com.backendless.Backendless;
import com.backendless.servercode.IBackendlessService;
 
public class SampleService implements IBackendlessService
{
  public WeatherInfo getWeather( SomeJsonObject arg  )
  {
    String plainJson = //call to external service to get data
    WeatherInfo weatherInfo = // use some json parser that you like to convert String to JSON, for example GSON
    return weatherInfo;
  }
}

deploy the code with coderunner. and now you can call the service read here how to work with service https://backendless.com/docs/bl-java/doc.html#bl_working_with_the_service2


(Okwui Agada) #7

I don’t see anywhere that WeatherInfo is defined. Does it have a URL? REST Endpoint, headers?


(Sergey Kukurudzyak) #8

It is just an example, your class can be instead of WeatherInfo, so it does not matter what fields are in the class