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

I am working with DialogFlow and attempting to set up a JSON object in PHP for use with DialogFlow fulfillment. The process is explained on this page.

My php script looks like this:

$myObj->fulfillmentText = "This is my test message";
$myObj->fulfillmentMessages = json_encode(array("text" => "text response")); 
$myJSON = json_encode($myObj);
echo $myJSON;

Open in new window

If I send only the first parameter, "fulfillmentText" it works fine because that is sent as a string.
But the second parameter, "fulfillmentMessages" is supposed to be sent as an object, but I'm not doing something right.  I get back this message from DialogFlow.

Fulfillment Text
  "fulfillmentText": "Searchby Choice is searchby|theme :: email| :: ",
  "fulfillmentMessages": "{\"text\":\"text response\"}"

Fullfillment Response (the error code)
Webhook call failed. Error: Failed to parse webhook JSON response: Expect an array but found: "{\"text\":\"text response\"}".

So I am clearly not setting up the array/object correctly in my php code to be recognized as an "array" in DialogFlow.  So how do I send the parameter "text" as an object array? What do I need to change in my PHP.

This reference page shows the correct setup for this option in dialogflow.

Thanks in advance for the assistance.
OWASP: Forgery and Phishing
LVL 12
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.


I know we have a good number of experts here and very experienced, now I need guidance on the VBA function that can retrieve the data from Json format like below:
"code": "500",
"Naration": "OK",
"declared-info": {
"Receipt-code": "3333333",
"Receipt-number": "111111",
"Customer-ID": "1025360",
"Customer-vat ": "78963102",

I hope you can see the parameters above, the VBA function when run need to grab the data from those parameters from the point of sales machine (POS). The accomplishment here is to ensure that the receipts that are created from the POS machines are not recaptured into Ms Access Application , instead they must be automated to avoid errors, this is the requirement by our client of which we do agree the concept.


Quick overview of JSON tokens

please provide me a few sentences to explain JSON tokens. I have worked with JSON on various full stack positions, and wonder how JSON tokens fit in.


I have this json that I want to convert to vb.net objects:

"status": "success",
"result": {
"0": {
"id": 4991,
"sender_id": 2971,
"due_date": "0000-00-00 00:00:00",
"language_id": "sv",
"last_event": "2017-05-17 09:58:38",
"visible_name": "new offer",
"name": "new offer",
"reminder_date": "0000-00-00",
"offer_status": 0,
"offer_type": 1,
"user_details": "{\"first_name\":\"Beta\",\"last_name\":\"\",\"company\":\"Simplesign\",\"email\":\"beta@yopmail.com\",\"reg_no\":\"\",\"address\":\"\",\"telephone\":\"00923453596885\",\"post_code\":\"\",\"city\":\"\"}",
"unique_id": "591c02ae8c442",
"created_date": "2017-05-17 09:58:38",
"signed_date": "0000-00-00 00:00:00",
"last_sent_emailreminder": "0000-00-00 00:00:00",
"last_sent_smsreminder": "0000-00-00 00:00:00",
"unread_notification": 0,
"offer_rejected": 0,
"recieved_by": 0,
"pdf_url": "https://esign.simplesign.io/avtal/downloadpdf/4991/5b8648da173a5",
"details": [
"id": 5668,
"offer_sent_id": 4991,
"customer_id": 1556,
"offer_status": 1,
"sent_date": "2017-05-17 09:59:15",
"email_read_date": "0000-00-00 00:00:00",
"document_read_date": "0000-00-00 00:00:00",
"signed_date": "0000-00-00 00:00:00",
"reject_date": "0000-00-00 00:00:00",
"sender_ip": "",
"read_ip": "",
"signed_ip": "",
"gps_location": "",
"first_name": "John",
"last_name": "Doe",
"company": "",
"is_sender": 0,
"extra_fields": "",

Open in new window

I have a working Google Maps API code example that plots a single location on a map based on an address.  However, .. I need to somehow adapt it so that it plots MULTIPLE different locations on the map (again based on the address).  How would I revise the code example below to achieve something like that?  I'd be open to loading the multiple different addresses from an Array or JSON object if it's easier.  My working code example is below.

- Yvan

<!DOCTYPE html>
        #myMap {
            height: 400px;
            width: 100%;
<h3>My Google Maps Demo</h3>
<div id="myMap"></div>
    var googleMaps = {
        mapLoad: function (address, mapDiv) {
            var mapOptions = {
                zoom: 20,
                mapTypeId: google.maps.MapTypeId.HYBRID,
                disableDefaultUI: true,
                gestureHandling: 'none',
                zoomControl: false
            var map = new google.maps.Map(mapDiv, mapOptions);
            geocoder = new google.maps.Geocoder();
            geocoder.geocode({ 'address': address }, function (results, status) {
                if (status == 'OK') {
                    var marker = new google.maps.Marker({
                        map: map,
                        position: results[0].geometry.location

Open in new window

Hi Experts

Could you point what is needed to make a PHP page to works out like a Web-Service?

Actually the page runs at browser this way:


Open in new window

The page is perfectly running. No errors.

To make it runs as a Web-server I guess it first must to receive a json string, isn't it?

The page:

    define('DB_HOST'        , "xxx.xxx.x.xx");
    define('DB_USER'        , "xxxxx");
    define('DB_PASSWORD'    , "XXXXXXX");
    define('DB_NAME'        , "xxxxxxxx");
    define('DB_DRIVER'      , "sqlsrv");
    $pdoConfig  = DB_DRIVER . ":". "Server=" . DB_HOST . ";";
    $pdoConfig .= "Database=".DB_NAME.";";

    $cpf     = isset($_GET['cpf'])     ? $_GET['cpf']     : 'null';
    $nome    = isset($_GET['nome'])    ? $_GET['nome']     : 'null';
    $apelido    = isset($_GET['apelido'])    ? $_GET['apelido']     : 'null';
    $genero    = isset($_GET['genero'])    ? $_GET['genero']     : 'null';
    $data_nascimento    = isset($_GET['data_nascimento'])    ? $_GET['data_nascimento']     : 'null';
    $tel_celular    = isset($_GET['tel_celular'])    ? $_GET['tel_celular']     : 'null';
    $tel_fixo    = isset($_GET['tel_fixo'])    ? $_GET['tel_fixo']     : 'null'; 

Open in new window

Using you favourite text editor (I use PHP storm and VSCODE)
Is there a feature to incremental renaming  while multi selecting here is pseudo desired output.
Note:there will be code in between which does not need changing imagine it's a JSON file and all I wan to do is change the id number incrementally.
I want the code to look beautiful but have Bugphobia .
Let me explain my fear:I am afraid to add wired spaces to break my code I want a convention to help me make it look nice without breaking it.
this is  post request of the real code where I changed the secret fields to pseudo fields .
look how beautiful the JavaScript looks like but it's deceiving as i am going to transform all VALUES into variables later (json does not like variables).
Here is the javascript (which looks good ):

var data = JSON.stringify({
  "fields": {
    "horse_colour": "brown",
    "birth_date": "2011",
    "sire_name": "sire name",
    "dam_name": "dam name"

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {

xhr.open("POST", "https://breeding-portal.mystagingwebsite.com/wp-json/acf/v3/listings/726");
xhr.setRequestHeader("authorization", "Basic bG93ZXNhbGV4QGdtYWlsLmNvbTpNYXJ0eW1jZmx5MTIz");
xhr.setRequestHeader("content-type", "application/json");


Open in new window

This is a working C# code using RESTSHARP (which I am looking for a pretty way to organise it READY FOR VARIABLES.(the values).

var client = new RestClient("https://breeding-portal.mystagingwebsite.com/wp-json/acf/v3/listings/726");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Basic bG93ZXNhbGV4QGdtYWlsLmNvbTpNYXJ0eW1jZmx5MTIz");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "\t{\n  \"fields\": {\n\t\t\"horse_colour\":\"brown\",\n\t\t\"birth_date\":\"2011\",\n\t\t\"sire_name\":\"sire name\",\n\t\t\"dam_name\":\"dam name\"\n  }\n}\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request); 

Open in new window

Searching though a JSON with php and jquery

I have some code that querys a DB with php and put the info in a json array here is my code

<link rel="stylesheet" type="text/css" href="PrintMeThatLabel.css" />
<script src = "cookie.js" type="text/javascript"> </script>

<script src = "jquery-1.4.3.min.js" type="text/javascript"> </script>
<script src = "http://www.labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.3.0.js" type="text/javascript" charset="UTF-8"> </script>
<script src = "PrintMeThatLabel2.js" type="text/javascript" charset="UTF-8"> </script>
<style type=text/css>

.text {color: #000; font-family:Arial, Helvetica, sans-serif }
.head {color: #000; font-family:Arial, Helvetica, sans-serif }
.input {display:none;}

.tftable {font-size:12px;color:#333333;width:100%;border-width: 1px;border-color: #729ea5;border-collapse: collapse;}
.tftable th {font-size:12px;background-color:#acc8cc;border-width: 1px;padding: 8px;border-style: solid;border-color: #729ea5;text-align:left;}
.tftable tr {background-color:#d4e3e5;}
.tftable td {font-size:12px;border-width: 1px;padding: 8px;border-style: solid;border-color: #729ea5;}
.tftable tr:hover {background-color:#ffffff;}



    <div class=text align="center">

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" >

<span class=text>Enter Work Order #: </span>
<input type="text"  name="Work_Order" length="30"  value="">


Open in new window


I have a JSON array passed back to javaScript from a PHP / MS-SQL table extraction.   The table has 100 fields and 2,000 records so the JSON array has 100 "key":"value" pairs and 2,000 rows.

From this JSON array In javaScript, I would like to create another JSON array of all 2,000 rows from it, but with only 2 of its 100 key:value pairs. These two for example (ItemCode and ItemName):

{"ItemCode" : "1234567", "ItemName" : "Widget", "...." : "....", }, { .... }

How can I do that in javaScript?

Another question:

How can I do it being sure there are no duplicates of the 2 key:value pairs in the new array?
Exploring ASP.NET Core: Fundamentals
LVL 12
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

How to export all my data in to a json array

Here is my code

ini_set('display_errors', TRUE);


$UsrWorkOrder = $_POST['Work_Order'];

//db connect info
include 'conn.php';
//Where the query are stored 
include 'Query.php';

$result_Vis = odbc_exec($conn_Vis,$sql_Vis);  // Get Data From Result
    while($row2 = odbc_fetch_array($result_Vis))
//Store the data in the new array


            $result_cor1db01_2 = odbc_exec($conn_cor1db01_2,$sql_cor1db01_2);  // Get Data From Result

            while($row3 = odbc_fetch_array($result_cor1db01_2))

//This stores the data 
            	$Barcode = $row3["Work Order No"]."-". $row3["Serial No"];
       			$part = $row2["PART_X"];
        		$DESCR = $row2["DESCR_X"];
            	$Cable_Length = $row3["ValueInches"];
            	$MFG = $row3["Work Order No"]."-". $row3["Serial No"];
            	$Test_A = number_format($row3["Value1"],2);
            	$Test_B = number_format($row3["Value2"],2);

                    Echo "<br><br><img src=barcode.php?codetype=Code128B&size=80&text=".$row3["Work Order No"]."-". $row3["Serial No"] ." />";
                    Echo "<br>".$row3["Work Order No"]."-". $row3["Serial No"]."<br>";
                    Echo "Part Number: ".$part."<br>";
                    Echo "Description: " .$DESCR."<br>";
                    Echo "Mfg Lot Number: " .$row3["Work Order No"]."-". $row3["Serial 

Open in new window

Using JsonResult causes the form submission to ask the user if they want to download the json file?

My controller is:

        public ActionResult Edit(int id)
            tbl_MyTable tbl = (from x in DB.MyTable
                             where x.ID == id
                             select x).Single();

            return View(edit);


        public JsonResult Edit(List<newList> formData)
            var result = new { Success = "", Message = "" };
                   foreach (var item in formData)
                    tbl_MyTable  Data = (from x in DB.tbl_MyTable
                                             where x.ID == item.ID
                                             select x).Single();

                    Data.Type = item.Type;
                    Data.Name = item.Name;
                    Data.Version = item.Version;
                    Date = item.Date;

                TempData["msg"] = "<script>swal('Item successfully updated!');</script>";


            catch (Exception ex)
                Utility util = new Utility();
                string error = util.innerExcep(ex);
                result = new { Success = "False", Message = error };
                return Json(result);

            result = new { Success = …
For some reason, maybe due to schema or lack thereof, my JSON documents are flagged with "Unexpected character sequence in member name".

And also, the member names do not have quotes around them when I first open the document, but then either through process of saving or modifying the documents, the member names get surrounded with double-quotes.

 View: "vAnnouncements",


"View": "vAnnouncements",

I could use some help with this!

I just recently ran "Get Latest" from the TFS, so the double-quotes problem corrected as a result.  But I am still getting the "Unexpected character" thing.

I Have this JSON
[{"uuid":"ead6b1c6-700c-446b-a96d-4809a00ba119","name":"BECCOFINO","created_at":"2017-05-08 09:26:07","updated_at":"2018-09-18 15:35:10","deleted_at":null,"levels":{"level2":[{"type":"F&B","uuid":"d7dc52f6-8b94-4ae2-9d7e-9e72b1f03853","name":"Beccofino","created_at":"2018-09-18 15:33:58",      "updated_at":"2018-09-18 15:42:21","deleted_at":"2018-09-18 15:42:21","customer_uuid":"ead6b1c6-700c-446b-a96d-4809a00ba119"},{"type":"Con_tact","uuid":"f7c4c881-88cb-433c-9bd7-9057fe8239d3","name":"Andrea Rotolli","created_at":"2018-09-18 15:38:08","updated_at":"2018-09-18 15:42:08","deleted_at":"2018-09-18 15:42:08","surname":"Rotolli","forename":"Andrea",      "prop_Gender":"Male","prop_Seize":"UXXXL","customer_uuid":"ead6b1c6-700c-446b-a96d-4809a00ba119"}]},"categories":["Auto Return","Available in Track"],"sync":"customer"}]

with these classes
    Public Class cls_JSON_Levels_Header_New
        Public uuid As String
        Public name As String
        Public created_at As String
        Public updated_at As String
        Public deleted_at As String
        Public levels() As cls_JSON_Levels_Body
        Public categories() As String
        Public sync As String
    End Class

    Public Class cls_JSON_Levels_Body
        Public level2() As cls_JSON_Level_Details
        Public level3() As cls_JSON_Level_Details
    End Class

    Public Class cls_JSON_Level_Details
        Public type As String
        Public uuid As String
        Public name As …
Hello Expert,

Could anybody please through light on following query. How json table works here !

SELECT ext.legacy_id        legacy_id,
                               ext.record_type      record_type,
                               ext.tran_type        tran_type,
                               ext.corp_id          corp_id,
                               ext.mdse_co_id       mdse_co_id,
                               json.loc             location,
                               ext.sty_cd           sty_cd,
                               ext.sty_clr_cd       sty_clr_cd,
                               ext.mkt_cd           mkt_cd,
                               ext.unit_price       unit_price,
                               ext.effective_date   effective_date
                          FROM risprc.ris_legacy_price_stg ext,
                               json_table('['||ext.excep_str_nbr||']', '$[*]' COLUMNS loc  NUMBER PATH '$') json,   --How it works?
                               TABLE (CAST (L_loc_tbl AS NUMBER_TBL)) tbl
                         WHERE ext.record_type   = LP_corp_rec_type
                           AND ext.excep_str_nbr IS NOT NULL
                           AND ext.location      = VALUE(tbl) ;

Open in new window

I am trying to read in a JSON  stream and able to use it to look up the datatype of a property. please see below.
What do I need to call using JSON.net to structure a proper lookup of an array of elements,  Below is a summary what I would like to do:
1. Lookup to see if there is a match of one of the following keyword:- 'Device/AnalogInput/AnalogOutput ...'.  This list can vary at runtime hence I can not write a class for each keyword
2. if exist,  loop through the property to find out the data type of each property
For example
I check if there is a keyword called 'Device',  Once I find it exists, I would like to loop through to find the 'datatype' of each property. In this case, I would find out 'datatype' of property 'SystemStatus' is 'int'. Next, I would find out 'datatype' of property 'ObjectName' is 'string'.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Data;

namespace TestJSONLookup
    class Program
        static void Main(string[] args)
            string json = @"[
    'Device': [
        'property': 'SystemStatus',
        'dataType': 'int'
        'property': 'ObjectName',
        'dataType': 'string'
    'AnalogInput': [
        'property': 'PresentValue',
        'type': 'real'
    'AnalogOutput' : [

Open in new window

Migrating Oracle procedures which has JSON data as input and business validation to insert/ update/delete tables to MariaDB.

Can we use SQL_MODE to ORACLE and use the same procedure ? Or we need to rewrite it again.

Like few differences where we use JSON_PARSER.PARSER(<<my input JSON>>) or JSON_EXT.GET_NUMBER / JSON_EXT.GET_STRING in Oracle to get the values for specific keys. So can we directly use the same procedure to work on Mariadb by setting the mode or we need to rewrite the entire procedure.
Hi there, I am trying to connect to the TSheets(www.tsheets.com) API, and load all the job codes into a table . I can successfully connect and get the JSON, but I currently have to hard code the job code in order to get the info. I am stuck on how to get the codes via the keys/item in the dictionary.  In the example below, '5834988' is the job code, but I have to hard code it in. I just want to pull '5834988' via the dicationary.

Sample JSON:

 "results": {
  "jobcodes": {
   "5834988": {
    "id": 5834988,
    "parent_id": 0,
    "assigned_to_all": true,
    "billable": false,
    "active": true,
    "type": "regular",
    "has_children": false,
    "billable_rate": 0,
    "short_code": "",
    "name": "Job 1000"


Set p = JsonConverter.ParseJson(jsonStr)
    For Each key In p("results")("jobcodes").Keys
        Debug.Print p("results")("jobcodes")("5834988").item("id")
        Debug.Print p("results")("jobcodes")("5834988").item("parent_id")
        Debug.Print p("results")("jobcodes")("5834988").item("active")
        Debug.Print p("results")("jobcodes")("5834988").item("type")
        Debug.Print p("results")("jobcodes")("5834988").item("name")
    Next key
Hi Experts!

Could you suggest the beter way to convert this json structure to a PHP array?

  "numeroGuia": "sample string 1",
  "paciente": {
    "nome": "sample string 1",
    "endereco": {
      "cep": "sample string 1",
      "logradouro": "sample string 2",
      "numero": 3,
      "complemento": "sample string 4",
      "bairro": "sample string 5",
      "cidade": "sample string 6"
    "dataNascimento": "2018-10-22T17:53:58.4603585-03:00",
    "cpf": "sample string 2",
    "telefone": "sample string 3",
    "email": "sample string 4",
    "sexo": "sample string 5",
    "peso": 1.1,
    "convenio": 1,
    "plano": "sample string 6",
    "matricula": "sample string 7"
  "contratante": {
    "tipo": 64,
    "contrato": 1
  "atendimento": {
    "diagnostico": "sample string 1",
    "recurso": "sample string 2",
    "exames": "sample string 3",
    "carater": 64,
    "motivoAtendimento": "sample string 4",
    "cid": "sample string 5",
    "produto": "sample string 6"
  "captacao": {
    "cor": "sample string 1",
    "dataInicio": "2018-10-22T17:53:58.4759589-03:00",
    "dataFim": "2018-10-22T17:53:58.4759589-03:00"
  "origem": {
    "dataAgendadaChegadaOrigem": "2018-10-22T17:53:58.4759589-03:00",
    "nomeLocal": "sample string 1",
    "endereco": {
      "cep": "sample string 1",
      "logradouro": "sample string 2",
      "numero": 3,
      "complemento": "sample string 4",
      "bairro": "sample string 5",

Open in new window

JavaScript Best Practices
LVL 12
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

How do i work with this data ?

above is the column

below is the data structure in this column

data structure
i am formatting it as json in the column but how do i access is on php from i pull it from the data and select the values of ids i want ?
I'm trying to learn about web APIs and was wondering if you could help me with a simple one to retrieve information about an online image.  An example URL could be

How could I build a RESTful API which accepts the image url as a parameter and retrieve information about the image must be retrieved responding in JSON format.  Is it also possible to create a web client to call the API.  It only needs a single page to accept input for the url, a button to call the API, and an area to display the response.

I'm using C# within Visual Studio 2017 community edition.
Hello -

I need help formatting a sharepoint column with JSON.  I am using O365 which allows custom formatting of columns using JSON.  I need to keep the column format as a number format (cannot use text format) and need to basically replace the thousands comma with a hyphen.  So, a number like 18,212 would show up at 18-212.

Again, I can't change the column format to be text.  I have very limited experience with JSON, so any help would be appreciated.
Hi, I have a python script that is creating a DataFrame from some json data.
I can create a DataFrame (df) from the data, but I need to create a DataFrame from the 'readings' column within the df DataFrame. My code is failing because the 'readings' column is a list.
Ultimately I need to create a DataFrame with the two DataFrames combined:

DataFrame needed
This is the python code I'm working with:

import pandas as pd
import json

data = {  
val = json.loads(json.dumps(data))

val1 = val['parameters']

#val2 = [{'timestamp': 

Open in new window

How do I extract parent values and all child values from deserialized JSON, one record per child value, to a List<T>?

Sample JSON:  json_sample.txt

So from the attached sample JSON we wish to add the following records to the  list:
Record 1:  aen: Y456789, studentID: 1016, need: MMM, rank: 1
Record 2:  aen: Y456789, studentID: 1016, need: PPP, rank: 2

All records with "needs : null" to be ignored and all "need": "Not Specified" to be ignored. Sample code below:

      CTFNeedDataBatch =
                           (from people in myJSON.content
                            select new NeedCTF
                                studID = people.StudentBasic.studentId.ToString(),
                                AEN= people.StudentBasic.aen.ToString(),
                                Code = (people.StudentSensitive.needs == null ? people.StudentSensitive.needs[0].need.ToString() : ""),
                                Priority = (people.StudentSensitive.needs == null ? people.StudentSensitive.needs[0].rank.ToString() : ""),
                            }).Where(w => w.Code != "").ToList();

The problem with this code is we are not getting any values from the "needs" element and even if we were, I doubt we would be getting more than one record from an element that has more than one need.

Using Python I'm trying to read a json string and output it to a dataframe, but I get the following error:

TypeError: 'float' object is not subscriptable

code is here:
# We import the requests module which allows us to make the API call
import pandas as pd
import ast
import json
import requests

# Call API to pull data
url = 'https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22'

response = requests.get(url = url)
response_data = response.json()

#data = response_data

data = """{  
         'description':'light intensity drizzle',

val = ast.literal_eval(data)
val1 = json.loads(json.dumps(val))
val2 = val1['main']['temp'][0]
dataset = pd.DataFrame(val2)

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