1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
| #include #include const int MAX = 3;int Sum (int, int);void Sum (char *, char *);void Sum (int [][MAX], int [][MAX]);void main(){ int a, b; char x[10], y[10]; int mat1[MAX][MAX], mat2[MAX][MAX], tot[MAX][MAX]; clrscr(); cout<<"\n Integers:- "< cout<<"\n Enter value of a: "; cin>>a; cout<<"\n Enter value of b: "; cin>>b; cout<<"\n Strings:- "< cout<<"\n Enter value of x: "; cin>>x; cout<<"\n Enter value of y: "; cin>>y; cout<<"\n Sum of Strings "< Sum(x, y); cout<<"\n Integer Matrices:- "< cout<<"\n Enter values in Matrix mat1: "; for(int i=0; i for(int j=0; j cin>>mat1[i][j]; cout<<"\n Enter value in Matrix mat2: "; for(i=0; i for(j=0; j cin>>mat2[i][j]; cout<<"\n Sum of Matrices is:-"< Sum(mat1, mat2); getch(); }int Sum(int a, int b){ return (a+b); }void Sum(char *a, char *b){ int i = 0, j = 0; char c[20]; while(*(a+i) != '\0'){ *(c+i) = *(a+i); i++; } while(*(b+j) != '\0'){ *(c+i) = *(b+j); i++; j++; } *(c+i) = '\0'; cout< }void Sum(int m1[MAX][MAX], int m2[MAX][MAX]){ int tot[MAX][MAX]; for(int i=0; i for(int j=0; j tot[i][j] = m1[i][j] + m2[i][j]; cout<<" "< } cout< }} |
Java API call Example using GSON, org.json.json and Jackson [ Simple Get Call] and parsing result as JSON
import com.fasterxml.jackson.databind.JsonNode ; import com.fasterxml.jackson.databind.ObjectMapper ; import com.google.gson.* ; import org.json.JSONArray ; import org.json.JSONObject ; import java.io.* ; import java.net.HttpURLConnection ; import java.net.URL ; public class APICALL { public static void main (String[] args) throws IOException { // String url="https://mocki.io/v1/19a50724-c2e5-46a1-b457-543462cdfde2"; String url= "https://jsonplaceholder.typicode.com/users" ; String line ; StringBuilder resp= new StringBuilder() ; System. out .println(url) ; HttpURLConnection con= (HttpURLConnection) new URL(url).openConnection() ; con.setRequestMethod( "GET" ) ; con.setRequestProperty( "Accept" , "application/json" ) ; System. out .println(con.getResponseMessage()) ; System. out .println(con.getContentType()) ; InputStream inputStream=con.getInput...
Comments
Post a Comment
share your thoughts ....