Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class based C++ program to validate a Json string, it has only {,}, [,], and string key and string value. Your program gets

Write a class based C++ program to validate a Json string, it has only {,}, [,], and string key and string value. Your program gets a string from the user and uses a pointer-based stack to determine whether its parentheses are properly balanced/matched. Size of characters is less than 100. Assume that operator will enter only [,],{,}, :, a-z, ", , . Whitespace is acceptable too. You do not need to check if input Json string has a duplicate key or not.

Note that this problem is simplified version of Expression Evaluation problem (pg. 128 and 129), where two stacks are used for operators and operand.

A few examples are given below.

Enter a json string: { "a":"b"}

True

Enter a string: { "a":"b", "x":"y"}

True

Enter a string: { "a":"b", "x":"y"

False

Enter a string: { "a": "b" "x": "y" }

False Enter a string: { "a":"b", "x": [ { "r":"a" }] }

True

Enter a string: { "a":"b", "x": [ { "r":"a", "a":"b" }] }

True

Enter a string: {"x":[{"r":"a","a":"b"}],"a":"b","t":[{"r":"a","a":"b"}] }

True

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain the concept of employment at will.

Answered: 1 week ago