JSON file in mbed.

Dependencies:   MbedJSONValue SDFileSystem mbed

Fork of City_Game_JSON by Alex Vancoillie

Committer:
ajeet3004
Date:
Mon Nov 27 05:22:40 2017 +0000
Revision:
5:eedf89829452
Parent:
2:e6a095fc2274
ghjh

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AlexVC97 2:e6a095fc2274 1 #include "mission.h"
AlexVC97 2:e6a095fc2274 2 #include <iostream>
AlexVC97 2:e6a095fc2274 3 #include <sstream>
AlexVC97 2:e6a095fc2274 4
AlexVC97 2:e6a095fc2274 5 namespace VivesCityGame
AlexVC97 2:e6a095fc2274 6 {
AlexVC97 2:e6a095fc2274 7 std::string Mission::get_type()
AlexVC97 2:e6a095fc2274 8 {
AlexVC97 2:e6a095fc2274 9 return type;
AlexVC97 2:e6a095fc2274 10 }
AlexVC97 2:e6a095fc2274 11
AlexVC97 2:e6a095fc2274 12 int Mission::get_id()
AlexVC97 2:e6a095fc2274 13 {
AlexVC97 2:e6a095fc2274 14 return id;
AlexVC97 2:e6a095fc2274 15 }
AlexVC97 2:e6a095fc2274 16
AlexVC97 2:e6a095fc2274 17 std::string Mission::get_message()
AlexVC97 2:e6a095fc2274 18 {
AlexVC97 2:e6a095fc2274 19 return message;
AlexVC97 2:e6a095fc2274 20 }
AlexVC97 2:e6a095fc2274 21
AlexVC97 2:e6a095fc2274 22 std::string Mission::get_hint()
AlexVC97 2:e6a095fc2274 23 {
AlexVC97 2:e6a095fc2274 24 return hint;
AlexVC97 2:e6a095fc2274 25 }
AlexVC97 2:e6a095fc2274 26
AlexVC97 2:e6a095fc2274 27 bool Mission::get_deadline()
AlexVC97 2:e6a095fc2274 28 {
AlexVC97 2:e6a095fc2274 29 return deadline;
AlexVC97 2:e6a095fc2274 30 }
AlexVC97 2:e6a095fc2274 31
AlexVC97 2:e6a095fc2274 32 int Mission::get_deadlineTime()
AlexVC97 2:e6a095fc2274 33 {
AlexVC97 2:e6a095fc2274 34 return deadlineTime;
AlexVC97 2:e6a095fc2274 35 }
AlexVC97 2:e6a095fc2274 36
AlexVC97 2:e6a095fc2274 37 double Mission::get_latitude()
AlexVC97 2:e6a095fc2274 38 {
AlexVC97 2:e6a095fc2274 39 return latitude;
AlexVC97 2:e6a095fc2274 40 }
AlexVC97 2:e6a095fc2274 41
AlexVC97 2:e6a095fc2274 42 double Mission::get_longitude()
AlexVC97 2:e6a095fc2274 43 {
AlexVC97 2:e6a095fc2274 44 return longitude;
AlexVC97 2:e6a095fc2274 45 }
AlexVC97 2:e6a095fc2274 46
AlexVC97 2:e6a095fc2274 47 int Mission::get_radius()
AlexVC97 2:e6a095fc2274 48 {
AlexVC97 2:e6a095fc2274 49 return radius;
AlexVC97 2:e6a095fc2274 50 }
AlexVC97 2:e6a095fc2274 51
AlexVC97 2:e6a095fc2274 52 void Mission::from_json(MbedJSONValue& json)
AlexVC97 2:e6a095fc2274 53 {
AlexVC97 2:e6a095fc2274 54 type = json["type"].get<std::string>();
AlexVC97 2:e6a095fc2274 55 id = json["id"].get<int>();
AlexVC97 2:e6a095fc2274 56 message = json["message"].get<std::string>();
AlexVC97 2:e6a095fc2274 57 hint = json["hint"].get<std::string>();
AlexVC97 2:e6a095fc2274 58 deadline = json["deadline"].get<bool>();
AlexVC97 2:e6a095fc2274 59 deadlineTime = json["deadlineTime"].get<int>();
AlexVC97 2:e6a095fc2274 60 latitude = json["latitude"].get<double>();
AlexVC97 2:e6a095fc2274 61 longitude = json["longitude"].get<double>();
AlexVC97 2:e6a095fc2274 62 radius = json["radius"].get<int>();
AlexVC97 2:e6a095fc2274 63 }
AlexVC97 2:e6a095fc2274 64
AlexVC97 2:e6a095fc2274 65 std::string Mission::to_string(void)
AlexVC97 2:e6a095fc2274 66 {
AlexVC97 2:e6a095fc2274 67 /*
AlexVC97 2:e6a095fc2274 68 std::stringstream ss;
AlexVC97 2:e6a095fc2274 69
AlexVC97 2:e6a095fc2274 70 ss << "Type: " << get_type();
AlexVC97 2:e6a095fc2274 71 ss << "Id: " << get_id();
AlexVC97 2:e6a095fc2274 72 ss << "Message: " << get_message();
AlexVC97 2:e6a095fc2274 73 ss << "Hint: " << get_hint();
AlexVC97 2:e6a095fc2274 74 ss << "Deadline: " << get_deadline();
AlexVC97 2:e6a095fc2274 75 ss << "DeadlineTime: " << get_deadlineTime();
AlexVC97 2:e6a095fc2274 76 ss << "latitude: " << get_latitude();
AlexVC97 2:e6a095fc2274 77 ss << "Longitude: " << get_longitude();
AlexVC97 2:e6a095fc2274 78 ss << "Radius: " << get_radius();
AlexVC97 2:e6a095fc2274 79
AlexVC97 2:e6a095fc2274 80 return ss.str();
AlexVC97 2:e6a095fc2274 81 */
AlexVC97 2:e6a095fc2274 82
AlexVC97 2:e6a095fc2274 83 return "mission";
AlexVC97 2:e6a095fc2274 84 }
AlexVC97 2:e6a095fc2274 85 };