How to code this assignment JSON objects. Hint: Work on the methods in the order they are found in the documentation below. def swap_value(file_path: str, key: str, replacement): """ This function will be given a file path and a key. The file that the file path points to contains a json object. This function should, load the data in the file. Then replace the value associated with the key with replacement value. Then it should overwrite the current data in the file with the new changes. Finally it should return the old value. :param file_path: A path to file :param key: A key value in the JSON object saved in the file :param replacement: The new value that the key will be mapped to :return: The old value that the key used to be mapped to """ def update_transactions(file_path: str, transaction_list: list): """ You are part of a team tasked to create an application that helps bankers by saving their transactions for them. Your job within the project is to implement the feature that actually saves the transactions to the hard drive. The scope of your task is that you will be given a file path to where the data should be written and a list of bank transaction objects to be written to the file. The file will contain a JSON array of transactions that the banker previously saved. The bankers at this bank are silly sometimes and they make duplicate transactions, your function should remove the duplicate transactions in the transaction_list and update the existing transaction list saved in the file with the new transactions. Make sure when you are preforming the update of the new transactions that you overwrite old transactions (transactions that already exist in the file) with duplicate new transactions (transactions that are found in the transaction_list). You will know that a transaction is a duplicate if it has the same ID. In the end the file should contain a JSON list with transaction Objects that have been updated with the new information from the transaction_list. The JSON list should contain no transactions with the same ID. The transaction object referred to here in is outlined below. In actual testing of your code the professors transaction object will be used, which will have all the documented functionality. class Transaction: def __init__(self, id:int, type:str, amount:float): self.id:int = id self.type:str = type self.amount:float = amount def __str__(self): return f'Transaction[{self.id}] {self.type} ${self.amount}' def __hash__(self): return hash(self.id) def __eq__(self, other): return hasattr(other,'id') and other.id == self.id :param file_path: A path to file blank file that holds a JSON list of existing transaction and where the new transaction data should be written :param transaction_list: A list of transaction :return: None """

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
How to code this assignment JSON objects. Hint: Work on the methods in the order they are found in the documentation below. def swap_value(file_path: str, key: str, replacement): """ This function will be given a file path and a key. The file that the file path points to contains a json object. This function should, load the data in the file. Then replace the value associated with the key with replacement value. Then it should overwrite the current data in the file with the new changes. Finally it should return the old value. :param file_path: A path to file :param key: A key value in the JSON object saved in the file :param replacement: The new value that the key will be mapped to :return: The old value that the key used to be mapped to """ def update_transactions(file_path: str, transaction_list: list): """ You are part of a team tasked to create an application that helps bankers by saving their transactions for them. Your job within the project is to implement the feature that actually saves the transactions to the hard drive. The scope of your task is that you will be given a file path to where the data should be written and a list of bank transaction objects to be written to the file. The file will contain a JSON array of transactions that the banker previously saved. The bankers at this bank are silly sometimes and they make duplicate transactions, your function should remove the duplicate transactions in the transaction_list and update the existing transaction list saved in the file with the new transactions. Make sure when you are preforming the update of the new transactions that you overwrite old transactions (transactions that already exist in the file) with duplicate new transactions (transactions that are found in the transaction_list). You will know that a transaction is a duplicate if it has the same ID. In the end the file should contain a JSON list with transaction Objects that have been updated with the new information from the transaction_list. The JSON list should contain no transactions with the same ID. The transaction object referred to here in is outlined below. In actual testing of your code the professors transaction object will be used, which will have all the documented functionality. class Transaction: def __init__(self, id:int, type:str, amount:float): self.id:int = id self.type:str = type self.amount:float = amount def __str__(self): return f'Transaction[{self.id}] {self.type} ${self.amount}' def __hash__(self): return hash(self.id) def __eq__(self, other): return hasattr(other,'id') and other.id == self.id :param file_path: A path to file blank file that holds a JSON list of existing transaction and where the new transaction data should be written :param transaction_list: A list of transaction :return: None """
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY