如何使用Javascript创建接口?

时间:2018-12-07 11:21:05

标签: javascript json xml interface

在我的实习期间,研发部门负责人要求我为使用Javascript的API创建接口。现在我对Java语言还很陌生,遇到了我的第一个问题,那就是我需要在Javascript代码中为接口实现JSON字符串。

我对JSON非常不熟悉,我已经在Google上搜索了信息,发现它是一种基于Javascript的更具可读性的语言?现在,这并不能带给我更多的东西。你们当中有人对我如何解决这个问题有想法或主张吗?

以下是API的一些JSON字符串:

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>`

您会看到JSON格式下还有一种XML格式。

0 个答案:

没有答案