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

In my .net c# project I have two jason like this


Open in new window


Open in new window

I need to compare this to json and get the result of the modified part oly

Open in new window

Thank you for your help!!
Will your db performance match your db growth?
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

I am trying to change a SP so that the email generated is an array, currently is just one fixed entry, the current syntax works but doesnt work with the API because the email needs to be an array.

Here is the current SP which works fine with a fixed email :

ALTER PROCEDURE [dbo].[api_cc_all_active_contacts] 
    DECLARE @json_result [NVARCHAR](MAX) = '';
    DECLARE @json_resultot [NVARCHAR](MAX) = ''; 

   SELECT   @json_result += CASE WHEN LEN(@json_result) = 0 THEN ''
                                ELSE ', 
                           END + '[{"email_addresses":"' + a.Email
                           + '","first_name": "' + ISNULL(a.FirstNm,'')
                           + '","last_name": "' + ISNULL(a.LastNm,'')
                           + '", "custom_fields":[ {"name": "contact_status", "value":"'
                           + CAST(ISNULL(a.Archivedcont,'0') AS varchar(10))
                           + '" },{"name": "country_of_birth", "value":"'
                           + ISNULL(a.PobCountry,'')
                           + '" }, {"name": "nationality", "value":"' + ISNULL(a.Nationality,'')
                           + '" }, {"name": "immigration_status", "value":"'
                          + ISNULL(a.NiStatus,'')
                           + '" }, {"name": "employer", "value":"' + ISNULL(b.MaidenNm,'') + '" } ]}]'
    FROM   dbo.Users a
           LEFT JOIN Users AS b ON b.UserId = a.EmployerId

Open in new window

I am displaying records from the database like this:

				url: 'functions/list-articles-delete.php',
				dataType: 'json',
				method: 'POST',
				success: function(data) {
				 $.each(data, function(item){
					var tr_str = "<tr>"
					+ "<td>" + data[item].n_title + "</td>"
					+ "<td>" + data[item].n_dateTime + "</td>"
					+ "<td><button class='btn btn-danger' id='deletebut' data-id='" + data[item].id + "'>Delete</button></td>";
					 $( "#output" ).append(tr_str);
					 $( "#deletebut" ).on('click', function(){
						// display id of associated record

Open in new window

When I click on any of the buttons I want it to console.log() the id of the associated record but not quite sure how to do this?
I am trying to create a Json object in C# that I will convert to XML.   I have a repeating set of Fees that I need to add to the json object.

Here is my code so far:

root.Deal.Fees = new ExpandoObject();
List<ExpandoObject> feeArray = new List<ExpandoObject>();

foreach (DataRow ro in ds.Tables["fees"].Rows)
    root.Deal.Fees.DealFees.Fee.Description = ro["fee_type"].ToString();;
    root.Deal.Fees.DealFees.Fee.Amount = ro["amount"].ToString();


Open in new window

No sure what else is needed.   Supply a different example if that is easier for you.
Thank you
I am trying to run json linq query in Visual Studio 2008. I am getting the error :

select is not a member of newtonsoft.json.linq.array

Below is my code

Dim APIURL As String = "https://mydomain/api/v1/enrollments/search?id=12345"
            Dim req As WebRequest = WebRequest.Create(APIURL)
            req.ContentType = "application/json; charset=utf-8"
            req.Credentials = New System.Net.NetworkCredential("xyz", "123")
            req.Method = WebRequestMethods.Http.Get

            Dim text As String = ""
            Dim dt As DataTable = New DataTable
            Dim res As Stream = req.GetResponse().GetResponseStream
            Dim reader As New StreamReader(res)
            Dim response As String = reader.ReadToEnd()


              Dim parsedObject = JObject.Parse(response)

            Dim docs = JArray.FromObject(parsedObject("enrollments")).Select(Function(x) x.ToObject(Of jSonClass.Enrollment)()) 'Error here
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?
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 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


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
Percona Live Europe 2017 | Sep 25 - 27, 2017
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

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

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
How to parse the  JSON Data using Rest web service give me a simple example
Setting up LaraDock for Laravel
Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Dear Experts,
I'm new with sending data in Json format,
Reading posted data in Json format is ok for me. ( Thanks to Ray Paseur )

I use below code on my json.php page. When I visit json.php page, I'm expecting the code runs and the page posts $jsonData to the myurl.php . Normally when I post a data with html form, my page is going to action page, and I'm expecting here the same, I'm waiting to go myurl.php but json.php goes nowhere and it gives no error.

PHP works when a page is called, right? So that I guess, it doesn't post anything, right?

I'm using shared hosting with PHP 5.6


//API Url
$url = 'myurl.php;

//Initiate cURL.
$ch = curl_init($url);

//The JSON data.
$jsonData = array(
    'username' => 'MyUsername',
    'password' => 'MyPassword'

//Encode the array into JSON.
$jsonDataEncoded = json_encode($jsonData);

//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);

//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);

//Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 

//Execute the request
$result = curl_exec($ch);

Open in new window

//the code is here: http://thisinterestsme.com/sending-json-via-post-php/
  I have the following JSON . How do I parse it and  get the data value [80,75,3,4,20] as base64 string in javascript

Thanks for your help

"contentHeaders" : {
"Content-Disposition" : attachment; filename=\"e.docx\"; filename*=UTF-8''e.docx,
"Content-Type" : application/vnd.openxmlformats-officedocument.wordprocessingml.document
"data" : {
     "type" : Buffer,
      "data" : [
"filename" : e.docx
I am trying to implement a search function in MVC.   In my controller I am returning a JSON Request so I can implement AJAX popup modal for crud.  In my search form in the view I call the view GetMembers which is just returning the JSON data.  I am confused on how to implement the search with the JSON part and keep the "regular list"  while still maintaining the AJAX for CRUD.

<div style="width: 90%; margin: 0 auto" class="tablecontainer">
        @using (Html.BeginForm("GetMembers", "Members100", true, FormMethod.Get))
            <b>Search By: </b>
            <input type="radio" onclick="ModifyPlaceHolder(this)" id="ID" name="searchBy" value="members_id" placeholder="Member ID" checked><label for="ID"> ID</label>
            <input type="radio" onclick="ModifyPlaceHolder(this)" id="Phone" name="searchBy" value="members_phone"><label for="phone"> Phone</label>         
            <input type="text" id="MyQuery" name="search" placeholder="ID">
            <input type="submit" value="search" />

    <table id="myDatatable">
            <th>renewal date</th>


Open in new window

 $(document).ready(function () {
        var oTable = $('#myDatatable').DataTable({
            "paging": false,
            "ajax": {
                "url": "@Url.Action("GetMembers", "Members100")",
                "type": "get",
                "datatype": "json"
            "columns": [
                { "data": "member_id", "autoWidth": true },
                    "data": "member_id",
                    "autoWidth": "50px",
                    "render": function(data) {
                        return '<a class="popup" href="http://localhost/NAHP/Members100/save/' +
                            data +

Open in new window


Open in new window

Dear Experts,
I'd like to learn about PHP and Json, ( posting and receiving data )

How would I post below $myJSON object to myjson.php page ? and how would I print it on the myjson.php page?
Can I post it inside an HTML form? Do I have to use Ajax or something?

What I'm looking for is a good working example. I tried this

$myObj->name = "John";
$myObj->age = 30;
$myObj->city = "New York";

$myJSON = json_encode($myObj);

echo $myJSON;

Open in new window

I tried to post it like this but it didn't work I only get "{" as a result when I use below code

<form name="form1" method="post" action="myjson1.php">
  <label for="data"></label>
  <input type="hidden" name="data" id="data" value="<?php echo $myJSON ; ?>">
  <input type="submit" name="send" id="send" value="send">

Open in new window

$data = $_POST['data'];
echo $data;

Open in new window

I have a table called XYZ which has 2 fields one is storing Json Structure and the other is varchar, Those fields look like below.
             HostName, IPAddresses
Row 1 : Machine1, {"ipaddress1":"", "ipaddress2":""}
Row 2 : Machine2, {"ipaddress1":"", "ipaddress2":""}
Row 3 : Machine3, {"ipaddress1":"", "ipaddress2":""}
Row 4 : Machine4, {"ipaddress1":"", "ipaddress2":""}
Row 5 : Machine5, {"ipaddress1":"", "ipaddress2":""}
and I have finished to extract the detail of ip address by using select Hostname , IPAddresses -> '$.ipaddress1' as PrimIP from XYZ

My Question is how can I use "in"  this keyword or something similar for those Json structure as I was using it in a normal SQL structure.
ie. let say I have a range of IP address of the ipaddress1. ('', '','' )
if the IP range is as varchar I can simply using

select hostname , IPaddresses from XYZ where IPAddresses in ('', '','' ).  roll consisted with these ip address will be return.

How can I do the same as above when I am using Json structure at MySQL?
Hi Guys,

I'm trying to read json list object through ajax:
Here is my json data return - which basically return 2 rows:
[{"BinLocation":"16A","BuydownPrice":0.0000,"BuydownQuantity":0.0,"CommissionAmount":0.0000,"CommissionMaximum":0.0000,"CommissionMode":0,"CommissionPercentProfit":0.0,"CommissionPercentSale":0.0,"Description":"3  B/G H.D. MYLAR  K","FoodStampable":false,"HQID":139858,"ItemNotDiscountable":false,"LastReceived":"2007-06-07T00:00:00","LastUpdated":"2013-01-18T16:24:06","Notes":null,"QuantityCommitted":0.0,"SerialNumberCount":0,"TareWeightPercent":0.0,"ID":1,"ItemLookupCode":"0839420-EA","DepartmentID":8,"CategoryID":614,"MessageID":0,"Price":0.7900,"PriceA":0.0000,"PriceB":0.0000,"PriceC":0.0000,"SalePrice":0.0000,"SaleStartDate":null,"SaleEndDate":null,"QuantityDiscountID":0,"TaxID":1,"ItemType":0,"Cost":0.2282,"Quantity":27.0,"ReorderPoint":0.0,"RestockLevel":0.0,"TareWeight":0.0,"SupplierID":316,"TagAlongItem":0,"TagAlongQuantity":0.0,"ParentItem":0,"ParentQuantity":6.0,"BarcodeFormat":7,"PriceLowerBound":0.0000,"PriceUpperBound":0.0000,"PictureName":"","LastSold":"2012-12-04T00:00:00","ExtendedDescription":"","SubDescription1":"THE HILLMAN 

Open in new window







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

Top Experts In