0

At my internship the head of R&D department asked me to create an interface for their API with Javascript. Now I'm quite new to Javascript and I've encountered my first problem, which is I need to implement the JSON strings in a Javascript code for the interface.

I'm quite unfamiliar with JSON, I've search info on Google and found out it was a more readable language based from Javascript? Now this doesn't exactly brings me any further. Any of you guys have an idea or proposition on how I can approach this issue?

Here are some JSON strings of the API:

Body Parameters

AccountCredentials

Name    Description Type    Additional information
username            string          None.
password            string          None.

Request Formats

application/json, text/json

Sample:

`{
  "username": "sample string 1",
  "password": "sample string 2"
}`

Application/xml, text/xml

Sample:

`<AccountCredentials xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.com/ProdistERP.Web.API.Controllers">
  <password>sample string 2</password>
  <username>sample string 1</username>
</AccountCredentials>`

As you can see there is also a XML format under the JSON format.

georg
  • 211,518
  • 52
  • 313
  • 390
  • First, read [JSON](http://www.json.org/) on Wikipedia. It is a data interchange format, just like XML (but much simpler and easier to use). You can generate it in JavaScript using `JSON.stringify(something)`. To answer anything else, unfortunately, you don't provide much details. – Amadan Dec 07 '18 at 11:28
  • First, JSON is a string based format through which server/client communicate. Second, by interface, I guess they meant a class/ constructor function. You can refer following URL: http://www.phpied.com/3-ways-to-define-a-javascript-class/ – Rajesh Dec 07 '18 at 11:28
  • Possible duplicate of [Safely turning a JSON string into an object](https://stackoverflow.com/questions/45015/safely-turning-a-json-string-into-an-object) – Liam Dec 07 '18 at 11:31
  • @Rajesh: by *interface for their API* they probably mean the specification of a REST-based web API. – Wiktor Zychla Dec 07 '18 at 11:31

0 Answers0