Question: Write a class to validate a Json string, it has only {,}, [,], and string key and string value. Your program gets a string from

Write a class 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 character in the strings of parentheses is less than 100. The valid chars are [,],{,}, :, a-z, ", , Whitespace is acceptable too. You do not need to check if input Json string has a duplicate key

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!