By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Using JSON for formatting?


New Coder
I was given a job assessment quiz and I think it has a JSON related question on it by mistake as my work is in C, C++, assembler, and python. But it looks interesting so I want to try to solve it. Here is what it asks and I have provided a facsimile of the tuples.

Using a JSON library (be sure to identify which library you use), write a function that will
format a message with the following schema:

Name      Value/Format

Name               string
DOB                mm/dd/yyyy
Channel data    array of 2
  Shift             enum
  Rate             float

The data should be passed to this function as a pointer to a structure.  The resulting
string is also passed as a pointer to a buffer.

I have looked at some JSON intro sites and to me it looks more like a way to store data rather than format it. Maybe there is a formatting function in one of the libraries. As a start I assume I setup the data tuples, maybe like this?
    "Name" : "Newbie"
     "DOB" : {
                   "month" : 2,
                    "day" : 6,
                  "year" : 1954

    "Channel data" :
         "Shift" : 2,
         "rate" : 75.00

         "Shift" : 1,
         "rate" : 15.00
I have no idea about schemas or library formatting functions. I am sure I can find websites about schemas but I have no clue about libraries or searching them.
So I have a few questions.

What is JSON, where do I find the libraries and search them?
Is there a schema lib?

Can the libraries be used with C or C++?

If you can answer any of my questions or offer some advice it would be much appreciated.

New Threads

Latest posts

Buy us a coffee!

Top Bottom