CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2023
    Posts
    2

    Lightbulb need help with json please

    Hello i new to this forum hope every one doing well

    weather website and starting to learn json as i am using willy weather api need hope with this code please what am, Idoing wrong

    [CODE]
    [H
    Code:
    {
        "CONTENT_TYPE": "application/json",
        "HTTP_X_PAYLOAD": {
            "platform": "iphone",
             "weatherTypes": [
                {
                    "code": "weather"
                }
            ],
            "mapTypes": [
                {
                    "code": "radar-rainfall"
                }
            ],
            "graphKeyTypes": ["wind"],
            "forecastGraphTypes": ["precis"],
            "observationalGraphTypes": ["dew-point"]
        }
    }
    site to code is https://www.willyweather.com.au/api/...by-location-id

    i also have to put in my own api could some one help me please as i wish to get the raain radar in the json formmate and thank you

  2. #2
    Join Date
    Dec 2013
    Posts
    5

    Re: need help with json please

    Clearly, you have to make https calls to that Rest API. I don't know if that service already provides a Java "client" library for its Rest API. It would be (reasonably) easy to use. For what I can see on that website, it seems there is no Java library available.

    In this case you have to develop your own little Java layer to make https calls to that API. And thus you have to choose a Java HTTP(S) client library like the Apache HTTPClient, OkHttpClient, the HttpClient introduced in Java/JDK 11, etc...

    So what have you done so far? Please, clarify. In other words, at what level are your doubts? Don't you know how to do HTTP(S) calls in Java? Or how to use an HTTP(S) client library? Or what else?
    Last edited by andbin; January 16th, 2023 at 12:17 PM.

  3. #3
    Join Date
    Jan 2023
    Posts
    2

    Re: need help with json please

    no not sure on how do HTTP(S) calls in Java? is there any tutorials on this and thankyou

  4. #4
    Join Date
    Dec 2013
    Posts
    5

    Re: need help with json please

    Quote Originally Posted by wildstorms View Post
    no not sure on how do HTTP(S) calls in Java? is there any tutorials on this and thankyou
    If you can use at least a Java/JDK 11 (or higher), then you can use the new Http Client API (package java.net.http). There is a quick introduction on the openjdk site: Introduction to the Java HTTP Client.

    Otherwise, you can use the OkHttp library. Or another library like the Apache HttpClient.

    Note that both JDK HttpClient and OkHttp do not have direct/predefined support for binding to/from JSON/XML formats. You have to send/receive JSON as strings and convert by yourself those strings to/from Java objects using Jackson databinding or Gson (or any other less known JSON library).

    If you have other doubts, ask.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured