Advertisement
Guest User

Untitled

a guest
Apr 4th, 2014
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. //odpowiednik
  6. string jsonpseudo(string szukane,string body)
  7. {
  8.     szukane='"'+szukane+'"'+": "+'"';
  9.     int a=body.find(szukane);
  10.     if (-1==a) return "NIEMA";
  11.     body=body.substr(a+szukane.length());
  12.     a=body.find('"');
  13.     if (-1==a) return "NIEMA";
  14.     body=body.substr(0,a);
  15.     return body;
  16. };
  17.  
  18. int main()
  19. {
  20.     string body=R"raw(
  21.    {
  22.       "first_name": "Imie",
  23.       "last_name": "Nazwisko",
  24.       "image": "nazwa zdjęcia"
  25.    }
  26.    )raw";
  27.  
  28.     cout << "last_name" " = "<< jsonpseudo("last_name",body)<<endl ;
  29.     cout << "first_name" " = "<< jsonpseudo("first_name",body)<<endl ;
  30.     cout << "image" " = "<< jsonpseudo("image",body)<<endl ;
  31.     cout << "sex" " = "<< jsonpseudo("sex",body)<<endl ;
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement