Thread: how to read json file

  1. #1
    Registered User
    Join Date
    Jan 2020
    Posts
    20

    how to read json file

    How can we read JSON file using C++ Program

    1. Utility to read JSON file from file server

    2. Utility should run at scheduled time let’s say 6AM
    3. Error message if JSON file is not properly formatted
    4. Error message if Category is missing and ITEM need that Category to be saved.
    5. Entity mapping as per the given relationship in data model
    5. Documentation for the API, preferably using any tool
    6. Junit Test cases using Mockito
    7. Use either MySQL or Oracle for API development
    8. add one point as JSON validation for not null and value range

    Thanks

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Search the Web for a JSON parser for C++
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2020
    Posts
    20
    Quote Originally Posted by laserlight View Post
    Search the Web for a JSON parser for C++
    But how to write program code for reading JSON file from file server
    then it should also achieve below functions as well:-

    Utility should run at scheduled time let’s say 6AM
    3. Error message if JSON file is not properly formatted
    4. Error message if Category is missing and ITEM need that Category to be saved.
    5. Entity mapping as per the given relationship in data model
    5. Documentation for the API, preferably using any tool
    6. Junit Test cases using Mockito
    7. Use either MySQL or Oracle for API development
    8. add one point as JSON validation for not null and value range

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Junit Test cases using Mockito
    Your specs imply the use of Java; why are you asking about how to do it using C++?

    Tim S.


    Quote Originally Posted by bintech21 View Post
    How can we read JSON file using C++ Program

    1. Utility to read JSON file from file server

    2. Utility should run at scheduled time let’s say 6AM
    3. Error message if JSON file is not properly formatted
    4. Error message if Category is missing and ITEM need that Category to be saved.
    5. Entity mapping as per the given relationship in data model
    5. Documentation for the API, preferably using any tool
    6. Junit Test cases using Mockito
    7. Use either MySQL or Oracle for API development
    8. add one point as JSON validation for not null and value range

    Thanks
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    slash7 with Amy Hoy >> Blog Archive >> Help Vampires: A Spotter’s Guide

    Is he obviously just waiting for some poor, well-intentioned person to do all his thinking for him?

    Can you tell he really isn’t interested in having his question answered, so much as getting someone else to do his work?
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  6. #6
    Registered User
    Join Date
    Jan 2020
    Posts
    20
    any updates by experts please here is the detailed requirement:-


    1. Utility to read JSON file from file server


    2. Utility should run at scheduled time let’s say 6AM


    3. Error message if JSON file is not properly formatted


    4. Error message if Category is missing and ITEM need that Category to be saved.


    5. Entity mapping as per the given relationship in data model


    5. Documentation for the API, preferably using any tool


    6. Junit Test cases using Mockito


    7. Use either MySQL or Oracle for API development


    8. add one point as JSON validation for not null and value range










    Validation Points:





    Step 1: You have to read the file, If any Error, please correct.


    Step 2: IF any category/item Missing, Null Message came or Any notification.


    Step 3: Add the category and save the message,


    Step 4: if Order not received it 6 AM, then Not file Uploaded Message must show OR repeat the previous order.


    Step 5: Must add clock in Programmer.



    Someone wants to manage their website. One of
    the most important pages on their website is the “Menu” page.The menu gets updated every
    night at the restaurant and Joe’s grill wants the updated menu published to their website every
    morning. customer will upload their menu in a JSON formatted file (Let’s call it menu.json) to our
    ftp server every night.
    Requirement is to develop a program to take this menu.json file and store the data
    in a relational database. The data model for the database tables is defined as follows.
    Data model
    Code:
    items: id(pkey), name
    categories: id(pkey), name
    category_items: id(pkey), category_id (fkey categories), item_id(fkey items)
    menu.json
    {
    "category”:[{
    “name”: “Appetizer”,
    },
    {
    “name”: “Entree”
    }
    ]
    ],
    "item”:[
    {
    "name":"French Fries",
    "category":"Appetizer"
    },
    {
    "name":"Onion Rings",
    "category":"Appetizer"
    },
    {
    "name":"Sandwich",
    "category":"Entree"
    },
    {
    "name":"Tacos",
    "category":"Entree"
    },
    {
    "name":"Ice Cream Sundae",
    "category":"Dessert"
    }
    ],
    "restaurant":"Joe's Grill"
    }
    }
    Existing classes:
    class category:
    def __init__(self, name):
    self.name = name
    class item:
    def __init__(self, name, category_name):
    self.name = name
    self.category_name = category_name
    Helper Functions that Already exist
    // json.get_categories(file_name) -> returns array of active category objects (category.name)
    // json.get_items(file_name) --> returns array of item object (item.name, item.category_name)
    // db.write(table_name, <a data dict or an array of data dicts>) //db.write('categories', {'name':
    'c1'})

    Note:The keys of the dictionary are the table column names, the values are the row values in
    the database table

  7. #7
    Registered User
    Join Date
    Jan 2020
    Posts
    20
    also let it be solved here on C++ forum main thing is problem should be solved technology language is secondary.

    Thanks

  8. #8
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    948

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Moved to the jobs board.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. JSON Advise for C++
    By JessicaS in forum C++ Programming
    Replies: 5
    Last Post: 03-19-2016, 05:39 AM
  2. Replies: 2
    Last Post: 12-07-2014, 07:01 AM
  3. Head First C Google Map associated with JSON file
    By Vesnog in forum C Programming
    Replies: 4
    Last Post: 04-05-2014, 05:57 PM
  4. Replies: 7
    Last Post: 12-07-2012, 10:44 PM
  5. How can I know the actual bytes read in a file read
    By pliang in forum C++ Programming
    Replies: 1
    Last Post: 06-08-2005, 04:23 PM

Tags for this Thread