Tag: json

Unable to make a $http.get request to a local JSON file using Angular

I’m making a weather application where I need to grab a local JSON file from within my controller and then do stuff with the data. However, I can’t get a local $http.get request to work for some reason. What should I do? This is my current code: var weatherApp = angular.module(‘weatherApp’, []); weatherApp.controller(‘weatherCtrl’, function ($scope, […]

Create a specific object array in javascript

I need to create an object array in javascript with this structure: var nodes = { ‘0’: { ‘label’: ‘abc’ }, ‘1’: { ‘label’: ‘cdf’ }, ‘2’: { ‘label’: ‘kjh’ }, ‘3’: { ‘label’: ‘wef’ }, ‘4’: { ‘label’: ‘vrg’ } }; I have tried like this but with no success 🙁 var nodes = […]

Format JSON Datetime on client side by Javascript or Jquery

Possible Duplicate: Convert a date to string in Javascript I have date in json format at client side : /Date(1352745000000)/ The code which i have tried to parse Json date: eval(dateTime.replace(/\/Date\((\d+)\)\//gi, “new Date($1)”)); and new Date(parseInt(dateTime.substr(6))); Out put I am getting: Tue Nov 27 2012 00:00:00 GMT+0530 (India Standard Time) Desire Output 2012-11-27 11:16 I […]

How to get only numerical key value pair from json

I have a Json data like this { “info”:[ { “Name”:”Noob Here”, “Major”:”Language”, “Sex”:”Male”, “English”:”15″, “Japanese”:”5″, “Calculus”:”0″, “Geometry”:”20″ }, { “Name”:”Noob Here”, “Major”:”Calculus”, “Sex”:”Female”, “English”:”0.5″, “Japanese”:”40″, “Calculus”:”20″, “Geometry”:”05″ } ] } I need to get only the key value pair where the value is numerical data. Expected output { “English”:”15″, “Japanese”:”5″, “Calculus”:”0″, “Geometry”:”20″ }, { […]

Use Lodash to transform this nested json data

I’m new to lodash. I have this kind of json data. I already have 90-120 lines of code that parses it, does some calculation to it, and creates new json. It’s becoming a nightmare. I would like to ask help on how I can transform this json using lodash’s methods. http://pastebin.com/BjBLwJDA [ { “dates”: [ […]

Are all javascript variable JSON-serializable?

Can JSON.stringify convert ANY javascript variable into text? Or are there limitations (functions, prototypes, etc.)?

How to get the json return value

If I can get the following string ([{“data”:{“id”:”1″,”user_name”:”tutor”,”book”:”123″,”role”:”Tutor”}}]); How can I alert it? data.user_name show undefined. $.getJSON(‘http://mydomain.com/getmyDetail.php?jsoncallback=?’, function(data) { alert(data.user_name); }); } another question, if I would like to put some value to the URL, such as http://mydomain.com/getmyDetail.php?username=XXX&role=XXX , how to put into getJSON function, directly $.getJSON(‘http://mydomain.com/getmyDetail.php?username=’+username’+’&role=’+role+’&’jsoncallback=?’ ?

Javascript: Parse JSON output result

How can i retrieve the values from such JSON response with javascript, I tried normal JSON parsing seem doesn’t work [[“102”,true,{“username”:”someone”}]] Tried such codes below: url: “http://somewebsite.com/api.php?v=json&i=[[102]]”, onComplete: function (response) { var data = response.json[0]; console.log(“User: ” + data.username); // doesnt work

Save JSON data locally on the machine

I am using the following link to create a tree like structure: LINK this is my code : <!DOCTYPE html> <html> <head> <meta charset=”UTF-8″> <title>Tree Context Menu – jQuery EasyUI Demo</title> <link rel=”stylesheet” type=”text/css” href=”themes/default/easyui.css”> <link rel=”stylesheet” type=”text/css” href=”themes/icon.css”> <link rel=”stylesheet” type=”text/css” href=”demo.css”> <script type=”text/javascript” src=”jquery.min.js”></script> <script type=”text/javascript” src=”jquery.easyui.min.js”></script> </head> <body> <h2>Tree Context Menu and […]

Push an item into a JSON Array

I have a JavaScript function that makes an ajax call to an API, and gets a JSON array. Here is a sample of an array that I get: [ { “ErrorType”: “Errors”, “Explanations”: [ { “Explanation”: “Price Missing”, “Locations”: [ 25, 45 ] }, { “Explanation”: “Unit of measurement not valid”, “Locations”: [ 25, 301, […]