Articles & Videos



JavaScript Object Notation, or JSON, is human-readable text used when transmitting data objects consisting of attribute:value pairs between a server and a web application as an alternative to XML. JSON, while it is originally derived from JavaScript, is a language-independent data format. Code for parsing and generating JSON data is available in many programming languages.

Share tech news, updates, or what's on your mind.

Sign up to Post

So, I am really trying to get my head around JSON and I have tried this which works but I wanted to know if there is a better way to do it or if this okay. I am actually playing around with developing a hybrid mobile app which uses a php and mysql backend. I have to use ajax to retrieve data and I want to also use JSON.

This is the jQuery/Ajax. The double dollar signs are not a typo, that is the correct syntax for the application but it is identical to jQuery as far as I know.

$$( "#submit" ).click(function(e){
			success: function(data) {
				var len = data.length;
				for(var i = 0; i<len; i++) {;
					var user_name = data[i].user_name;
					$$( "#phpcontent" ).append(`
					<li class="item-content">
						<div class="item-inner">
						<div class="item-title">${user_name}</div>

Open in new window

This is the php for content.php

$stmt = $link->prepare("SELECT `user_name` FROM `users` ORDER BY `user_name` DESC");
$result = $stmt->get_result();
$numRows = $result->num_rows;
if($numRows > 0) {
	while($row = $result->fetch_assoc()) {
		$user_name = sanitize($row['user_name']);
		$return_array[] = array(
			"user_name" => $user_name
echo json_encode($return_array);

Open in new window

What I have noticed in all the examples I have looked at is that the database results have to be put into an array in order to use json_encode. Am I correct in saying that or is it just a coincidence that every example I looked at did that?
Enroll in June's Course of the Month
Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Basically make the markers update every second or so from the JSON file aswell as display the data in the JSON file i.e altitude callsign etc when clicking on marker.
I have a simple html page that uses bootstrap grid.

Each page of the grid I've labelled as a section.

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">


  <div class="container">

  	<div class="row">
  		<div class="col-md-4">Section 1</div>
  		<div class="col-md-4">Section 2</div>
  		<div class="col-md-4">Section 3</div>

  	<div class="row">
  		<div class="col-md-6">Section 4</div>
  		<div class="col-md-6">Section 5</div>


    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
   	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

Open in new window

Example data:

  "section": "section1",
  "position": "5"

Open in new window

What I want to do is to load the different grid parts by reading json data.

So basically, the page loads, reads the json data which contains the positions of the sections and then populates the website.
I am trying to get a json to vb.net class.
I have used the Visual studio converter for this and generated the class, but it is not working.
 The commented   ' Public Property Wlisting() As WooData does not work,
I have tried different methods of calling an array or a list but always get the same error.  The Json that come over appears correctly formed, it is the inability to get it into a class which is the problem.

The line :

  Dim WooResponse = JsonConvert.DeserializeObject(Of WooCommerceData.Results)(result)

gives the following error:
Newtonsoft.Json.JsonSerializationException: 'Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Zetsy.WooCommerceData.Results' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.

To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.

Zit appears I should be calling this as a differnt type of list, but what I have tried gives the same error

The class is the following:

Namespace WooCommerceData
    Public Class Results
        Public Property Wlistings As List(Of WooData)
        ' Public …
I am using a webclient to send data via JSON to tell the server what I want to have them return to me. However, The API requires I use a GET. But I don't know how to define a GET in the UploadData or even DownloadString methods. How can I issue a GET at the same time I am also sending JSON?

If I pass all the parameters as query string parameters it also fails, so I have to issue the call using JSON data in the body.

I am using REST API with SharePoint 2013 and I want to know if the following url endpoint is legal or if there is a better way?
 //http://myspsite.com/nrm/_api/web/lists/getbyTitle('My_Project_Modules')/items?$select=DIR,Station,Title,Building_x0020_Number&$filter=Project_x0020_Number eq '402-CSI-001'     //<---  Works when I paste it in the browser
 var projNum = '402-CSI-001';
var endPointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbyTitle('My_Project_Modules')/items?$select=DIR,Station,Title,Building_x0020_Number&$filter=Project_x0020_Number eq "+projNum;  //<---  Not valid when I run it in my code

Open in new window

Error I get in my js file
rest api error
js file
function loadSPItems() {
var projNum = '402-CSI-001';
var endPointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbyTitle('My_Project_Modules')/items?$select=VISN,Station,Title,Building_x0020_Number&$filter=Project_x0020_Number eq "+projNum;//,ProjectNumber,ApprovalStatus,ProjectExecutionStatus”;
var headers = { 
	"accept": "application/json;odata=verbose" 
	url: endPointUrl, 
	type: "GET", 
	headers: headers, 
success: function (data) {
	error: function (err) { 
	alert("Error Occured:" + JSON.stringify(err)); 


Open in new window

How to populate select options from database in jquery. I am using datatables editor plugin to edit the row.

var local_path = "/dashboardlocal_list/0/?format=json";
var local_editor = new $.fn.dataTable.Editor( {
        idSrc:  'id',
        ajax: {
            // create: {
            //     type: 'POST',
            //     url:  '/dashboard/local_detail/'+ idSrc +'/?format=api'
            // },
            edit: {
                type: 'PUT',
                url:  '/dashboard/local_detail/_id_/',
                data: function (d) {
                        var updated_data = {};
                        $.each( d.data, function (id, value) {
                            updated_data['description'] = value['description'];
                            updated_data['start_date'] = value['start_date'];
                            updated_data['end_date'] = value['end_date'];
                            updated_data['task.name'] = value['task.name'];
                                                             } );
                        return updated_data;

                success: function() {
            remove: {
                type: 'DELETE',
                url:  …

I have been playing with the following
from within a PHP app.

So far so good: I am able to show data coming from a PHP function (selecting data from a MySQL DB) and also able to export in JSON format to allow the chart to showup, but ...

...I find no way to change tooltip data, or simply change duration format (it seems I cannot decide a fixed format like h m s instead of the default by day).

The data I am using to feed the chart include hours, minutes and seconds

Anyone who has experience on this can confirm if:
 1 - It is possible to change duration format and how
 2 - It is possible to change tooltip content/format and how

Thanks in advance
Hye experts, i have a problem to display data in data datagrid based on searching..can someone look it up..
Thank you for your help

Here is my code: test3.php

include "utama.php";

<script type="text/javascript">
 function doSearch(){
        MUKIM: $('#mukim').val()

<table id="tt" class="easyui-datagrid" style="width:600px;height:250px"
        url="test4.php" toolbar="#tb"
        title="Load Data" iconCls="icon-save"
        rownumbers="true" pagination="true">
            <th field="MUKIM" width="80">MUKIM</th>
            <th field="KAWASAN" width="80">KAWASAN</th>
            <th field="NAMA_KAWASAN" width="80" align="right">NAMA_KAWASAN</th>

<div id="tb" style="padding:3px">
    <input name="MUKIM" id="mukim" class="easyui-combobox" style="width:100%"
            data-options= "label: 'MUKIM : ',
            valueField: 'MUKIM',
            textField: 'NAMA_MUKIM',
            url: 'dropdown_mukim.php'">
    <a href="#" class="easyui-linkbutton" plain="true" onclick="doSearch()">Search</a>

code test4.php

include "connection.php";
$mukim = isset($_POST['mukim']);

if (isset( $_POST ["mukim"] ))
    $mukim = $_POST ["mukim"];

// echo  $name ;
// echo $phone;
// echo $mukim;

I am working with a device that is accessible from the cloud.  The device is registered and active and can be accessed using POSTMAN.
I need to write a C# program using an API that specifies the URL for the call to the PING function.  All I need to do is authenticate and get a response to a POST to the URL for the PING function.

string UseThisURL = "https://myurl/v2/ping";

I have an API Key: 9999xxxxx8888
I have a UserId: 012345678
I have a Deviceid: 555566667777

The API specifies to use JSON

When I use a Content Type of "application/json", I get bad format.
When I use a Content  Type of "application/x-www-form-urlencoded", I get Unauthorized

I have two versions of my test program to create the request, one that serializes the parameters using JSON and one that builds a string.

I have JAVA source code that posts from a call through a JAVA program but I need to format my request using C#

The documentation says that the API key must be sent as a header.  

Here is a code snippet processes the request and throws the Bad Format exception. Module to create the request is also included.

     ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            var requestParams = new NameValueCollection
                        {"userId", UserId},
                        {"deviceid", Deviceid}

            HttpWebRequest http = …
i have  JSON from a firebase database and I want to put the data in an HTML table, preferably with Javascript

Tried a few examples on the web but cant get anything to work, Im not sure how to reference each piece of JSON
...trying things like snap.val().site and snap.val()[0].site and get error message undefined

can someone please point me in the right direction

"-KkKsqJ9VyBILEg-DOPX": {
"direction": "SSE",
"email": "anita@gmail.com",
"site": "Bridges",
"speed": "5-10",
"status": "Flyable",
"statusDescription": "Epic"
"-KkKvkBn_kAR0YB1hIX_": {
"direction": "E",
"email": "joe@gmail.com",
"site": "Moirs",
"speed": "10-15",
"status": "Flyable",
"statusDescription": "Its OK"

Open in new window

<table id="displayData">

Open in new window

<div id = "display"></div>

Open in new window

//reference table and div
const firedata = document.getElementById('displayData');
const display = document.getElementById('display');

//create reference
const dbRefObject = firebase.database().ref().child('posts' );

//sync changes
dbRefObject.on('value', snap => {
//Display data in an HTML Table

//display JSON in a div - works ok, returns the JSON above
  display.innerText = JSON.stringify(snap.val(), null, 3);

//display in console - works ok

Open in new window

Hello there,

I want to create a csv file from a JSON string which I get from the backend. But I need to select which of the key value need to go into the csv file. For e.g. below is my JSON which I get from the server. I want to only export 5 key values i.e.


Open in new window

Please help!!

i have a class that I am using JSON to read the data from. I am getting this error but not quite sure why when I am not seeing an array in my class

An unhandled exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll

Additional information: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[SpringAhead.Timecard]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.

To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.

Path '?xml', line 1, position 8.

Open in new window

Imports System.Xml.Serialization
''' <remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")>
<System.Xml.Serialization.XmlRootAttribute([Namespace]:="", IsNullable:=True)>
Partial Public Class SA

    Private timecardField As Timecard()

    ''' <remarks/>
    <System.Xml.Serialization.XmlElementAttribute("Timecard", IsNullable:=True)>
    Public Property Timecard() As Timecard()

Open in new window

I am having array of json object in java script and want to iterate in jsp.
we are using struts 1.1 kindly help.
I am using a JavaScript plugin called listjs.  For those that don't know about it, what it does is the following.
You configure a textbox as a search and then tag columns in a table with class names and use those names to configure the options on the listjs plugin.

The plugin will then rebuild your list allowing incremental search returns of rows have strings which match the search box values.  It mostly works, but with a hidden string which is a JSON structure it only partially works,  I can find matches for say  8 rows and when I add another character that still matches in order the 8 rows,  one or more rows disappears.

Also,  in jQuery,  I set the val() of the searchbox to what should return some rows, and it behaves as though nothing was entered.  It seems that it knows about keypress and using jQuery to plop the value in has no keypress.

Any advice on these issues would be greatlya appreciated.

Hello Experts,

I would know  is it possible to implement Auto suggest  through angularjs2. The application has to search  the database and suggest some alternate name while typing in the text.

Thank you
Dear Experts, I'mt rying to use GO to read a json file that I have.

I'm using the following code:
package main

import (

func main() {

	b, _ := ioutil.ReadFile("/home/david/jsontest/create.jsontest.campaigns.ninja.json")

	type UserData struct {
		user_id    string
		user_email string
		user_name  string

	type campaign struct {
		domain      string
		Ssl         int64
		server_key  string
		certificate string
		bundle      string
		php_ver     string
		wp          int64
		lang        string
		start_date  string
		end_date    string
		description string
		user_data   UserData
		CampaignID  int64

	var m campaign
	err := json.Unmarshal(b, &m)
	if err != nil {
		panic (err)
	fmt.Printf("%d", m.CampaignID)

Open in new window

When I run the code however, the Result is this:
/usr/lib/golang/bin/go run /home/david/GoglandProjects/CampaignsNinja/jsontest.go
Process finished with exit code 0

Which is correct, but partial.. I'm missing the 2nd value which should be 74 (according to the  attached JSON below)

{"domain":"jsontest.campaigns.ninja","ssl":1,"server_key":"","certificate":"","bundle":"","php_ver":"5.6","wp":1,"lang":"english","start_date":"2017-02-02","end_date":"2017-03-02","description":"This is a test","user_data":{"user_id":"74","user_email":"usertest@gmail.com","user_name":"usertest"},"CampaignID":80099700}

Any Ideas why is the code behaving that way?
Hi guys,

I'm very new to Go and I'm afraif the guides regarding JSON aren't very clear.

I have the following JSON output (saved as a .json file in a certain path) the content of which is

{"domain":"jsontest.campaigns.ninja","ssl":1,"server_key":"","certificate":"","bundle":"","php_ver":"5.6","wp":1,"lang":"english","start_date":"2017-02-02","end_date":"2017-03-02","description":"This is a test","user_data":{"user_id":"74","user_email":"usertest@gmail.com","user_name":"usertest"},"CampaignID":80099700}

and the following Piece of code written in Go:

package main

import (

func main() {
	type Message struct {
		domain      string
		ssl         int
		server_key  string
		certificate string
		bundle      string
		php_ver     string
		wp          int
		lang        string
		start_date  string
		end_date    string
		Description string

	var m Message
	err := json.Unmarshal(b, &m)

Open in new window

Where b should be the path to the json file.

but as you can see, the JSON itswelf has nested fields...

My question is,
and I'm sorry if it's a long one but I really tried looking it up just can't get the concept...
How do I include the nested fields in the structure called Message and how do I read each and every value into a variable (preferably not an array but a separate variable for each value)
I am displaying a tree in Angular2 application using angular-tree-component (https://angular2-tree.readme.io).

I need to give user the capability to select any node in the tree and delete it. This should remove the selected node and all it's children (if it's a leaf node, then just the node). When user is done, the pruned tree will be send to the server and saved there.

In the below example, user selects 'Node 1-2' and clicks on Delete. This removes 'Node 1-2, 'Node 1' and 'Node 2' from the view and underlying Javascript object updated. User can then click another button (say, Save) to save the updated object on the Server.
In order to accomplish this, I wrote the following code which is called on click of Delete button. I store the id of the selected node, and then iterate over the complete tree to find that id. When the id matches, I use the 'delete' keyword to delete 'id' and 'text'. However, 'delete children' does not work.

deleteSelectedNode() { 
    //Get the node which was selected by the user  
    let nodeToDelete: TreeNode = this.myService.getActiveNode();
    //id will be unique, can be used to identify the node
    let idToDelete = nodeToDelete.data.id; 
    this.traverseTree(this.nodes[0], idToDelete);

  traverseTree(obj, idToDelete: string) {

    for (var k in obj) {
      if (typeof obj[k] == "object" && obj[k] !== null) {
        this.traverseTree(obj[k], idToDelete);

      else {
        if (k === 'id') 

Open in new window

Containers and Docker for Everyone
Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

I have an ASP.Net 4.0 website and I am looking to integrate some JQuery to a web page but I don't know how.
I want to use IP Info API to look get the IP Address and City of the users on my site.  They have provided code snippets here:
How can I integrate this to the client side script of my web page and populate some text boxes with the results on page load?
Hi. I'm having input xml file, which having double quotes attribute, But i want to change as single quote while doing xml to json process. because json files not allowing double quotes:

My input xml file having:

                  <div class="text-center">
                        <strong> Type:</strong> Unhealthy fat</p>

for Json output I need as:

                  <div class='text-center'>
                        <strong> Type:</strong> Unhealthy fat</p>

I'm using saxon-PE and XSLT version as 3.0. How i can change the double quote to single quote??
I have a coldfusion query and I need to search the query by the address with the proximity of 5 miles. The client type their home address and I need to show desired location in the radius of 5 miles
Hello guys, I'm editing a file so I can get a chart as the team needs, but I actually don't know Json or JS. Can anybody hepl ?

This is the code for the plot I have today:

	var seriesTitle = [['0 - 5 days'],['6 - 10 days'],['11 - 20 days'],['21 - 30 days'],['31 - 60 days'],['61 - 90 days'],['More than 90 days']];
  plot3 = $.jqplot('chart3', [[sla_5],[sla_10],[sla_20],[sla_30],[sla_60],[sla_90],[sla_plus]], {
	title: '<b>Aging Incidents per Categories',

    // Tell the plot to stack the bars.
    stackSeries: false,
	seriesColors:['#0ba500', '#659ed3','#f4eb02','#e2b01b','#d17b63','#8b4513','#e2251b'],
    captureRightClick: true,
      rendererOptions: {
        //   Put a 30 pixel margin between bars.
          barMargin: 40,
        //   Highlight bars when mouse button pressed.
        //   Disables default highlighting on mouse over.
          highlightMouseDown:false , 
		  barDirection: 'vertical'
      pointLabels: {
		  show: true,
		  color: 'white',
		  hideZeros: true,
		  FontColor : "#FFFFFF"

            {label:'0 - 5 days - Total ' + sla_total[0]},
            {label:'6 - 10 days - Total ' + sla_total[1]},
            {label:'11 - 20 days - Total ' + sla_total[2]},
			{label:'21 - 30 days - Total ' + sla_total[3]},
			{label:'31 - 60 days - Total ' + sla_total[4]},

Open in new window

How to parse the  JSON Data using Rest web service give me a simple example
I am having a very complex string that I need to tokenize and also create name pair values when possible. Here is a sample of the strings I have

Recod Style 1
Search Result Queries;SomeHotel.com;PT\=89030726\;PA\=-1119567914\;PS\=1547518063;2017-05-13 01:43:36.719;Search Results Query BT SPLIT=checkInDate\=5-13-2017&checkOutDate\=5-14-2017&numberOfAdults\=1&propertyIds\=MS140|MS741|MS1290|MS1334|MS1349|MS4557|MS4568|MS4783|MS4854|SS6029,Web Requests - Client IP=;Execution Time Informix=2404.003662109375,DB Count=2.0,DB Time=2404.0037887319922;false;;2424.760498046875;2424.760498046875;8.655830353498459;2424.7605440989137;;;;SomeHotel_PROD;dyntrc-mgmt.SomeHotel.com

Recod Style 2
Search Result Queries;Mobile App;PT\=89031695\;PA\=-1119567914\;PS\=1547518063;2017-05-13 01:44:17.772;Search Results Query BT SPLIT=checkInDate\=5-13-2017&checkOutDate\=5-14-2017&corporatePlusNumber\=&numberOfAdults\=1&propertyIds\=MS1173%7CMS4961%7CMS4376%7CMS4281,Web Requests - Client IP=;Execution Time Informix=1762.662109375,DB Count=5.0,DB Time=1759.847623437643;false;;1781.0732421875;1781.0732421875;10.074070394039154;1781.0732627734542;;;;SomeHotel_PROD;dyntrc-mgmt.SomeHotel.com

Both record styles happen in the same file.

Main delimiter above is;
some values are name-value pairs delimited on \= or =
Some fields contain other fields and delimited by &

Any ideas on how to parse this so I can convert it to some CSV or json





Articles & Videos



JavaScript Object Notation, or JSON, is human-readable text used when transmitting data objects consisting of attribute:value pairs between a server and a web application as an alternative to XML. JSON, while it is originally derived from JavaScript, is a language-independent data format. Code for parsing and generating JSON data is available in many programming languages.

Related Topics