Tag: json

IntelliJ IDEA如何正确地将$ NODE_DEBUG_OPTION传递给npm-run-all

在我的Ubuntu 16.04上,我将IntelliJ IDEA ultima 2017.2与节点v6.11.2和npm v3.10.10一起使用,并且要debugging一个node.js应用程序,它具有以下package.json start条目: "start:" "npm-run-all –parallel serve-static open-static" 根据控制台输出和这个类似的SO问题,我需要添加$ NODE_DEBUG_OPTION作为第一个参数(节点),以避免连接被拒绝的错误。 Obvioulsy,我试过了 在运行/debuggingconfiguration中添加$ NODE_DEBUG_OPTION作为参数 和节点选项 这导致了像 node npm-cli.js run start-debug –scripts-prepend-node-path=auto $NODE_DEBUG_OPTION 和 node $NODE_DEBUG_OPTION npm-cli.js run start-debug –scripts-prepend-node-path=auto 在每种情况下,$ NODE_DEBUG_OPTION都不parsing, 节点将其视为不存在的文件。 我也试图直接在package.json中添加variables "start:" "npm-run-all $NODE_DEBUG_OPTION –parallel serve-static open-static" 这也导致无法find模块… / $ NODE_DEBUG_OPTION错误。 那么,我怎么能通过这个选项来debuggingIntelliJ IDEA中的东西呢? 谢谢

来自string的JSON数组

我有一个存储在MySQL中的JSON图的数组。 当我从MySQL中获取这个信息时,它被作为一个长string给出。 我怎样才能恢复到使用JavaScript的JSON对象数组? 我正在使用NodeJS和MySQL包运行。 我的数据返回如下所示: '[{"x":0,"y":0},{"x":1,y:1},{"x":2,"y":2}]' 我希望能够做的是使用像这样的数据: var data = [{"x":0,"y":0},{"x":1,"y":1},{"x":2,"y":2}]; console.log(data[0].x); 我曾尝试使用JSON.parse,最初使用JSON.stringify存储数据,但它不像我所期望的那样运行。 有没有方法或软件包可以处理这个? 编辑:我现在意识到,这不是JSON,而是对象。 对于这里错误的术语抱歉,但我的问题仍然存在。

Node.js使用(JSONstring/ Arr?)

我正在运行node.js上的项目,但我从来没有使用过JSON。 我包括一个API,运行一个函数,并返回结果。 当我console.log结果我得到这个: { 'Sealed Graffiti | GLHF (Bazooka Pink)': { opskins_price: 2, market_price: 3, opskins_lowest_price: 2 } } 我如何处理这个结果? 例如访问opskins_price 。

JSON结果显示SUM MySQL的命令

我得到一个有效的返回计算所有值列我的MYSQL表,但是当我去检查我的api结果; 列值sum命令出现在JSON的结果中。 [ { "SUM(producFinalPrice)": 6000 } ] 这个我的路由器从我的数据库中获取数据。 router.get('/sell/home-card-last-sell-compared-to-the-previous-day', function (req, res) { connection.query('SELECT SUM(producFinalPrice) FROM new_sell', function (err, lastSellComparedToThePreviousDayCardHome, fields) { if (err) { throw err; } res.send(lastSellComparedToThePreviousDayCardHome); } ); }); ` 让我的错误更清晰,我从AJAX中的前一个查询做出最后的请求; 通过这种方式。 $(function () { $.ajax({ type: "GET", url: "/sell/home-card-last-sell-compared-to-the-previous-day", success: function (lastSellComparedToThePreviousDayCardHome) { var $lastSellComparedPreviousDay = $('#last-sell-compared-to-the-previous-day'); $.each(lastSellComparedToThePreviousDayCardHome, function (i, […]

从HTTP POST请求中检索JSON

我有以下function(基本上是从另一个SO问题的答案直接采取): function makePostRequest(requestURL, postData) { request( { url: requestURL, method: "POST", json: true, body: postData }, function(error, response, body) { console.log(response); }); } 当我用正确的requestURL调用它时,我成功地到达这条路线: router.post("/batchAddUsers", function(req, res) { console.log("Reached batchAddUsers"); }); 我一直在试图检索我发送的postData无济于事。 req.params和req.body都是{} 。 我没有弄清楚如何引用请求中传递的包含body的对象。 我读了整个console.log(req) ,发现没有用。 我之前做过这样的事情,除了请求是由一个表单来req.body的。 现在我正在做“手动”的请求,它不再工作。 整个事情在Node.js上运行。 我究竟做错了什么?

如何使用json插入非空列的表?

我试图用多个非空的默认列插入到food表中,命令如下: food_insertone('{"id": 1, "taste": "sweet"}'::JSON) food_insertone('{"id": 2}'::JSON) food_insertone('{"id": 3, "taste": null}'::JSON) 结果应该是这样的: INSERTED 1, 'sweet' INSERTED 2, '' ERROR (null not allowed in taste) 餐桌被定义为: CREATE TABLE "food" ( "id" INT, "taste" TEXT NOT NULL DEFAULT '', … ); CREATE OR REPLACE FUNCTION "food_insertone" (JSON) RETURNS VOID AS $$ INSERT INTO "food" SELECT * FROM […]

我如何取消一个exception的JSONvariables?

我试图做一个Node.js机器人,所以我find了一个模块,安装它,并试用其示例代码。 现在,我有一个asynchronous函数,从API加载一些文本。 这是代码: (async () => { // Display user's balance balance = kraken.api('Balance'); console.log(await balance); })(); 当我运行上面的代码时,这是我在commandprompt中得到的: { error: [], result: { A: '2.0', BC: '0.005', BCA: '111' } } 我怎样才能使它只logging这个看起来像一个数组的特定部分? 我试过做类似的东西(让它返回2.0): console.log(await balance.result.A) 但是,这似乎不工作,因为它返回这个: (node:6604) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'A' of undefined (node:6604) [DEP0018] DeprecationWarning: Unhandled […]

如何parsing节点js中的JSON数组

我正在尝试下面的代码,身体是来自HTTP GET响应。 当我试图运行它,我得到以下错误。 无法读取未定义的属性“ po_number ” { "d": { "results": [ { "po_number": "PO1001", "product_id": "PD1001", "message": "Exists", "timestamp": "2016-05-01" } ] } } 如何访问po_number var profile = JSON.parse(body); console.log("profile: "+ profile.results.po_number); 当我访问上面的代码时,我得到undefined

如何获取嵌套的JSON对象MongoDB的数据与node.js

我在我的MONGODB中有一个JSON对象 { "_id" : ObjectId("59d4b9848621854d8fb2b1e1"), "Bot_name" : "Scheduling bot", "Modules" : [ { "ModuleID" : "1111", "ModuleStatement" : "This is a Sceduling bot, Would you like to book a flight?", "_id" : ObjectId("59d4b9968621854d8fb2b1e3"), "ModuleResponse" : [ { "Response" : "yes", "TransBotID" : "1112" }, { "Response" : "no", "TransBotID" : "1113" } ] }, { […]

IONIC 3应用程序不正确发布JSON

我希望能得到这个帮助。 以下是我写的用于发送电子邮件和密码的代码。 这一切都看起来不错,直到它到达服务器。 服务器将其处理为: { '{"email":"email@gmail.com","pin":"1234"}': '' } 我不确定问题出在哪里。 我已经尝试通过邮递员发送电子邮件和pin,并且没有问题。 我甚至包含了POSTman创build的头文件(Content-Type:application / x-www-form-urlencoded),以确保我以同样的方式发送所有的信息。 这是我的离子代码: export class LoginPage { baseURL: string = 'http://localhost:1000/api' data: any; constructor(public navCtrl: NavController, public navParams: NavParams, private http: Http) { } login(email, pin) { let headers = new Headers(); headers.append('Content-Type', 'application/x-www-form-urlencoded'); let options = new RequestOptions({ headers: headers }); let body […]