Home Page > > Details

JSON AssignmentGhostwriter ,C++ Programming AssignmentDebug ,data AssignmentHelp With ,Ghostwriter C++ AssignmentGhostwriter R Programming|Ghostwriter Python Programming

For this part, we will perform conversion between JSON and C++ objects

Part 1.1
Please download and read this JSON -- http://cyrus.cs.ucdavis.edu/sfelixwu/ecs36b/s2020/hw5/base_input.json
A more readable representation of the same JSON can be found under –
http://cyrus.cs.ucdavis.edu/sfelixwu/ecs36b/s2020/hw5/styled_base_input.json

The above JSON represents an example of a social media post, similarly to Facebook. Under this post, we have the post itself with a unique identifier, its sender and receiver, comments, reactions, and timestamps for all relevant activities. Your assignment here is to design a set of C++ classes representing exactly the same data structure, and to write a C++ program to parse the input JSON, and then to put the information in this input JSON into C++ objects from those classes you designed. For instance, you might have classes to represent Post, Comment, and Reaction. Then, the Post portion of the JSON will be used as arguments to construct a C++ Post object.

To confirm that your design and implementation have correctly converted an input JSON into C++ objects. You need to write a function to re-construct a JSON (i.e., myOutput.json) from your own C++ objects. If you are doing the right conversion, the information content from base_input.json and myOutput.json should be equivalent. To validate the equivalence, you can download this program -- http://cyrus.cs.ucdavis.edu/sfelixwu/ecs36b/s2020/hw5/hw5parse.cpp

$ g++ -std=c++14 -I/usr/include/jsoncpp -o hw5parse hw5parse.cpp -ljsoncpp
$ ./hw5parse base_input.json > base_input_output.json
$ ./hw5parse myOutput.json > myOutputbase_output.json
$ diff base_input_output.json myOutputbase_output.json

Following the above steps, if the diff command shows nothing (i.e., no difference between those two files in the arguments of the command diff), then you have successfully converted the JSON to C++, and back to the equivalence of the original JSON.

Please note that hw5parse.cpp provides you an example of using the jsoncpp library to parse the JSON.

Part 1.2
For this part of assignment, you will write a program to merge two JSONs into one JSON, following the semantics of Post, Comment, and Reaction. For example, http://cyrus.cs.ucdavis.edu/sfelixwu/ecs36b/s2020/hw5/update_01_input.json is a JSON representing additional activities (e.g., a new reaction and a new comment) to the original Post, sharing the same Post_ID, in original JSON. So, your program will parse both JSONs (the first one is the original and the second one is the update) and produce one new JSON representing the combined activities related to this Post.

To confirm that your design and implementation have correctly merged two JSONs into a single combined JSON, we will provide test cases under http://cyrus.cs.ucdavis.edu/sfelixwu/ecs36b/s2020/hw5 for you to compare your answers with the expected ones.


Part 2.1

For this part, you will build two C++ programs, hw6client and hw6server, based on the following JSON RPC specification: http://cyrus.cs.ucdavis.edu/sfelixwu/ecs36b/s2020/ecs36b_hw6.json, which includes two RPC calls, (1) update(std::string post_json_str), and (2) search(std::string keyword). The details are given below:

update(std::string post_json_str) takes only one argument, which is a JSON string representing a POST, like what we had in HW#5. Your hw6server program receives it and performs the following actions:
1.check if the ID of the post already exists. Please note that this post might appear as a C++ Post object with the same ID, or as a Post JSON file for the same ID at the server side.
2.If the Post doesn’t exist yet, the server program will create a C++ Post object for this JSON Post
3.If this Post already exists, then this newly received post_json_str will be merged into the original Post, similar to hw5merge().
4.In either case, this newly created or merged post will be sent back to the caller client, again in Post JSON format as the response. Also, this new Post will be saved by the server in the JSON file format with the same ID as part of the file name. In other words, now this Post is a Persistent C++ Object.

search(std::string keyword)take only one argument, which is a JSON formatted search key word. For example, {“keyword”: “Patrick Jane”}. When the server hw6server receives this call, it will gather all the existing posts containing the same key (each post has a vector of key strings). Then, it will put all the gathered posts into a JSON array (which, BTW, is still a JSON) and sends it back to the client.

For testing your programs, we will provide a sequence of calls or actions (either update or search, plus ctrl-c, kill and program restarts), and the expected JSON results from the client side.

Part 2.2 (bonus)

(2%) Your hw6client program will check if the server is available, using the try/throw/catch C++ exception handling. If the server is unavailable, it will still continue, accessing only the local cache copy of the Post objects. For example, you can still update your local copies in JSON files with new comments or reactions. Then, when the server is back on-line, the client will then submit the updates to merge on the server. Again, we will provide a sequence of calls or actions to test your programs.

(2%) Instead of obtain the Posts via the search keyword, we can also select posts via GPS_DD locality or timestamp. In other words, we can have the following search clauses
1.{“distance”: 100, “latitude“: 38.5, “longitude”: -121.7}
2.{“updated_time”: “2020-05-02T16:45:18+0000”}
The first clause will return all the Posts within 100 miles range from the given GPS_DD coordinate, while the second clause will match all the posts having any update after the timestamp.

Contact Us - Email:99515681@qq.com    WeChat:codinghelp2
© 2014 www.asgnhelp.com
Programming Assignment Help!