Create a file called toJSON that reads a .txt file from the command line. This file should always contain at least three lines: • line 1: is a first name (1 word) • line 2: is a last name (1 word) • line 3: is a location (1 word) • lines 4-n: can be string(s) (n # of word(s)) Your job is to take this data and out a clean JSON object in the following format: fname: linel fname, lname: line2 lname, location: line_3, other: lines 4-lines_n The only edge cases that need to be considered are:

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
Create a file called toJSON that reads a .txt file from the command line. This
file should always contain at least three lines:
• line 1: is a first name (1 word)
• line 2: is a last name (1 word)
• line 3: is a location (1 word)
• lines 4-n: can be string(s) (n # of word(s))
Your job is to take this data and out a clean JSON object in the following format:
fname: linel fname, Iname: line2 lname, location: line 3, other: lines 4-lines_n
The only edge cases that need to be considered are:
• If there are not at least three lines in the file, print an error message and
do no further processing on the file
• Only one arg is read in through the command line which is the filename.
If more than one arg is provided, print an error message and do no further
processing on the file
• If there are only three lines, other will contain "N/A"
Transcribed Image Text:Create a file called toJSON that reads a .txt file from the command line. This file should always contain at least three lines: • line 1: is a first name (1 word) • line 2: is a last name (1 word) • line 3: is a location (1 word) • lines 4-n: can be string(s) (n # of word(s)) Your job is to take this data and out a clean JSON object in the following format: fname: linel fname, Iname: line2 lname, location: line 3, other: lines 4-lines_n The only edge cases that need to be considered are: • If there are not at least three lines in the file, print an error message and do no further processing on the file • Only one arg is read in through the command line which is the filename. If more than one arg is provided, print an error message and do no further processing on the file • If there are only three lines, other will contain "N/A"
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning