JSON

771

Solutions

767

Contributors

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'm new to Python, trying to teach myself the language.  I'm using Best Buy's API to test. I'm not sure how to format the JSON data so it's readable in HTML/CSS format. Can you assist?

import requests

url = "https://api.bestbuy.com/v1/products%28customerReviewAverage%3E4%7CshippingWeight%3C50%29"

querystring = {"show":"upc,salePrice,customerReviewAverage,shippingWeight","apiKey":"XXXXXXXXXXXXXX","format":"json"}

response = requests.request("GET", url, params=querystring)

print(response.text)

Open in new window


Here is how the JSON response looks.

{"from":1,"to":10,"currentPage":1,"total":190579,"totalPages":19058,"queryTime":"0.203","totalTime":"0.230","partial":false,"canonicalUrl":"/v1/products(customerReviewAverage>4|shippingWeight<50)?show=upc,salePrice,customerReviewAverage,shippingWeight&format=json&apiKey=XXXXXXXXXXXX","products":[{"upc":"760514017023","salePrice":442.99,"customerReviewAverage":5.00,"shippingWeight":11.00},{"upc":"877929006358","salePrice":489.98,"customerReviewAverage":4.80,"shippingWeight":30.80},{"upc":"664254218934","salePrice":320.99,"customerReviewAverage":5.00,"shippingWeight":11.00},{"upc":"612934533280","salePrice":249.99,"customerReviewAverage":5.00,"shippingWeight":7.30},{"upc":"664254011221","salePrice":171.99,"customerReviewAverage":5.00,"shippingWeight":11.00},{"upc":"068888879262","salePrice":132.99,"customerReviewAverage":4.80,"shippingWeight":7.85},{"upc":"612934536229","salePrice":1062.99,"customerReviewAverage":4.70,"shippingWeight":28.50},{"upc":"093207100253","salePrice":499.98,"customerReviewAverage":4.40,"shippingWeight":35.89},{"upc":"865334000122","salePrice":202.99,"customerReviewAverage":4.20,"shippingWeight":9.99},{"upc":"865334000115","salePrice":237.99,"customerReviewAverage":4.30,"shippingWeight":9.99}]}

Open in new window

0
CompTIA Cloud+
LVL 12
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Hi,

I need to serialize vb.net code to json.

I need the json to look like this:
{
    "KalTid": [
        {
            "AnstNr": "1",
            "Datum": "2014-01-02",
            "RadId": "9b8412eb-77a4-4e0b-853e-fdd78edeac8a",
            "UseTid": true,
            "StartTid": "08:00",
            "SlutTid": "08:00",
            "Timmar": 8,
            "Dagar": 0,
            "TidKod": "SJK",
            "UseBrukare": true,
            "UseResEnhet1": false,
            "UseResEnhet2": false,
            "UseResEnhet3": false,
            "Brukare": "1",
            "ResEnhet1": "",
            "ResEnhet2": "",
            "ResEnhet3": "",
            "Registrerad": true,
            "CalcTyp": "",
            "Source": "PORTAL"
        }
    ]
}

Open in new window


The vb.net classes I'm using are looking like this:
Imports Microsoft.VisualBasic
Imports Newtonsoft.Json

Public Class KalTid
    <JsonProperty("AnstNr")>
    Public Property AnstNr As Long

    <JsonProperty("Datum")>
    Public Property Datum As DateTimeOffset

    <JsonProperty("RadId")>
    Public Property RadId As Guid

    <JsonProperty("UseTid")>
    Public Property UseTid As Boolean

    <JsonProperty("StartTid")>
    Public Property StartTid As String

    <JsonProperty("SlutTid")>
    Public Property SlutTid As String

    <JsonProperty("Timmar")>
    Public Property Timmar As Long

    <JsonProperty("Dagar")>
    Public Property Dagar As Long

    <JsonProperty("TidKod")>
    Public 

Open in new window

1
Hi,

I have this json request that I want to deserialize to an vb object. The json looks like this:
{
    "PerReg": [
        {
            "AnstNr": "1",
            "EfNamn": "Ljunggren",
            "FoNamn": "Siv",
            "Adress1": "Föreningsgatan 33",
            "Adress2": "",
            "PostNr": "447 34",
            "PostOrt": "VÅRGÅRDA",
            "LandAdr": "",
            "EpostPriv": "",
            "EpostArb": "",
            "Telefon": "0322-21298",
            "Mobil": "",
            "PersNr": "197901049283",
            "Signatur": "SL",
            "Befattning": "VD",
            "AnstDatum": "2001-09-01",
            "Slutat": false,
            "AvgDatum": "1899-12-30",
            "AnstTom": "1899-12-30",
            "Locked": false,
            "KalSchemaAuto": false,
            "UseOBRegel": false,
            "LockOBRegel": false,
            "OBRegelID": "",
            "UseArbSchema": true,
            "ArbSchema": "1",
            "Avdelning": "10",
            "KalUseAttest": true,
            "PerTyp": "LED",
            "AnstForm": "TV",
            "LoneForm": "MÅN",
            "LSSBerPerStart": "1899-12-30",
            "LSSBerPerInt": "",
            "LSSAnnanArbGiv": false,
            "LSSArbGivNamn": "",
            "LSSArbGivOrgnr": "",
            "UseSysGrad": true,
            "SysGrad": 100,
            "VeckArbTid": 40,
            "HelVeckTid": 40,
            "VeckArbDgr": 5,
            "DagArbTid": 8,
        

Open in new window

1
Hi I am selecting data from mysql database in node red: -

my database value are as follows:-
dbtime.png
Code in node red as follows: -
 msg.topic ="Select DeviceId, Line, outPIN, count,Time FROM mytab LIMIT 1"

Open in new window


In debug node i do get the time in different format and unable to store in different location of database.

9/17/2018, 4:59:29 PMnode: 4f250b1.97196f4
INSERT INTO mytable1 (DeviceId,Line,outPIN,count,Time) VALUES (?,?,?,?,?) : msg.payload : array[5]
[ 2, 1, "7", 1, "2018-09-16T13:28:24.000Z" ]
9/17/2018, 4:59:29 PMnode: d00874f1.76f388
msg : error
"Error: ER_TRUNCATED_WRONG_VALUE: Incorrect datetime value: '2018-09-16T13:28:24.000Z' for column 'Time' at row 1"

Open in new window



How i can format the time back to normal 'yyyy-mm-dd hh:mm:ss'
0
HI, In node red, I did create node to count number of rows in "mytab" table.
msg.topic  = "SELECT COUNT(count) FROM mytab"; 

return msg;

Open in new window


Result from node-red after count total number of row in mytab table is.

SELECT COUNT(count) FROM mytab : msg.payload : string[20]
"[{"COUNT(count)":8}]"

I am trying to extract number of rows, in this case it is --> 8.

var obj = msg.payload;
var json = JSON.parse(obj);
var Device = json[0].COUNT(count);
msg.payload = Device;
return msg;

Open in new window


Error msg after executing pop up saying : -
function : (error)
"ReferenceError: count is not defined (line 4, col 28)"
0
I am extracting all data from mysql using Node-Red. Its give set of data in json format but with opening and closing quote to indicate as string format. I did try many ways to pull out particular line.

" [   {"ID":1,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:28:24.000Z","IdRef":1} ,
       {"ID":2,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:29:53.000Z","IdRef":1} ,
       {"ID":3,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:29:59.000Z","IdRef":1} ,
       {"ID":4,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:15.000Z","IdRef":1} ,
       {"ID":5,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:16.000Z","IdRef":1} ,
       {"ID":6,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:16.000Z","IdRef":1} ,
       {"ID":7,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:17.000Z","IdRef":1} ,
       {"ID":8,"DeviceId":2,"Line":1,"outPIN":"7","count":1,"Time":"2018-09-16T13:39:17.000Z","IdRef":1}   ] "

var obj = msg.payload;
var json = JSON.parse(obj);

var Device = json[1].Device_ID;
msg.payload = Device;
returen msg;

Open in new window


Error message as follows :

SELECT *FROM mytab : msg.payload : undefined
undefined
0
MQTT Publish done successfully at this stage with json format.

 data ='{"Device_ID":1,"Line_ID":1,"GPIO":7,"Count":1,"Date_Now":timenow}'
myjson = json.dumps(data)
publish.single("Productin/Line1", myjson , hostname="test.mosquitto.org")

Open in new window


MQTT @ Client site succesfully received with the following code.
# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
    print(msg.topic)
    print(msg.payload)
    count = 0
    payload = json.loads(msg.payload)
    #print(payload)
    json1 = JSON.parse(payload)
    device = json1.Device_ID
    print (device)
    if device == 1:

Open in new window


Print command give the following output
"{\"Device_ID\":1,\"Line_ID\":1,\"GPIO\":7,\"Count\":1,\"Date_Now\":timenow}"
{"Device_ID":1,"Line_ID":1,"GPIO":7,"Count":1,"Date_Now":timenow}

Open in new window


I am unable to print of device. May i know how to call the members of json.
0
Hello everyone. I need some help with this Colfusion component.. I need to pass the values extracted form the cfqueries into the values in the cscript...

<cfcomponent>
<!--- I have the following queries --->
<cffunction name="GetNumbers">
<cfquery name="Fall2006" datasource="#db#" > 
      select sum(transfer_y1_2y_public) as y12y, sum(transfer_y2_2y_public) as y22y, sum(transfer_y3_2y_public) as y32y, sum(transfer_y4_2y_public) as y42y, sum(transfer_y5_2y_public) as y52y, sum(transfer_y6_2y_public) as y62y from transfer where transfer_entry_sector = <cfqueryparam cfsqltype="cf_sql_varchar" value="TWO_YEAR_PUBLIC">
      and transfer_year = <cfqueryparam cfsqltype="cf_sql_integer" value="2006">
</cfquery>

<cfquery name="Fall2008" datasource="#db#" > 
      select sum(transfer_y1_2y_public) as y12y, sum(transfer_y2_2y_public) as y22y, sum(transfer_y3_2y_public) as y32y, sum(transfer_y4_2y_public) as y42y, sum(transfer_y5_2y_public) as y52y, sum(transfer_y6_2y_public) as y62y from transfer where transfer_entry_sector = <cfqueryparam cfsqltype="cf_sql_varchar" value="TWO_YEAR_PUBLIC">
      and transfer_year = <cfqueryparam cfsqltype="cf_sql_integer" value="2008">
</cfquery>

<cfquery name="Fall2010" datasource="#db#" > 
      select sum(transfer_y1_2y_public) as y12y, sum(transfer_y2_2y_public) as y22y, sum(transfer_y3_2y_public) as y32y, sum(transfer_y4_2y_public) as y42y, sum(transfer_y5_2y_public) as y52y, sum(transfer_y6_2y_public) as y62y from transfer where …
0
I want to disable a form submit if a div has a message contained within it.

I have a form that checks an external source for some validation. If the validation checks are not met, then a warning message is displayed in a div (dispemail).

I'd like to disable my submit button if a message is displayed in this div.

My form is:
<form action='formprocessor.php' method='post' id='member-add'>
<table cellpadding='5px' cellspacing='5' >
<tr><td>Email</td></tr>
<tr><td><input type='text' name='email' id='email' value=''/><div id='dispemail'></div></td></tr>
<tr><td><input type='submit' value='Submit' style='margin-top:20px; margin-bottom:40px' id='submit'/></td></tr>
</table>
</form>

Open in new window


The Javsacript to call the ajax validation script:
<script type="text/javascript">
$(document).ready(function(){
$("#email").blur(function() {
var email = $('#email').val();
if(email==="")
{
$("#dispemail").html("");
}
else
{
$.ajax({
type: "POST",
url: "check-email.php",
data: "email="+ email,
success: function(html){
$("#dispemail").html(html);
}
});
return false;
}
});
});
</script>

Open in new window


The validation code:
<?php

if(isset($_POST['email'])){
$email=(($_POST['email']));

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api.xxxxx.com",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_POSTFIELDS => "{}",
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo $response;
}


$responsetext=json_decode($response, true);

if ($responsetext['result']=='undeliverable'){
$message = $responsetext['email']." is not a valid email - ".$responsetext['reason'];
echo "<p class='error'>$message</p>";

}
else {
$message = $responsetext['email']." is a valid email";
echo "<p>$message</p>";
}



}

?>

Open in new window

0
I have this output of $a

Array
(
    [id] => cus
    [object] => customer
    [account_balance] => 0
    [created] => 15217df
    [currency] => 
    [default_source] => card
    [delinquent] => 
    [description] => Customer forfdgfdg
    [discount] => 
    [email] => 
    [invoice_prefix] => 353593C
    [livemode] => 1
    [metadata] => Array
        (
        )

    [shipping] => 
    [sources] => stdClass Object
        (
            [object] => list
            [data] => Array
                (
                    [0] => stdClass Object
(
[id] => card_fortest1

Open in new window


I want to be able to get "sources" so I can get sources[0][id], sources[1][id]..etc

Is there an easier way to do so?
0
Bootstrap 4: Exploring New Features
LVL 12
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Hi, i am runing program on Node-Red. The data format in JASON. I am trying to pull out "payload": "Open" and insert into mysql. No errors but the data in sql state as [object OBJECT] . Did attached the database field.

test2 : msg : Object
object
topic: "test2"
payload: "Open"
qos: 0
retain: false
_topic: "test2"
_msgid: "2356ede6.954ba2"

Open in new window


var temp;

temp ={"payload":msg.payload};
msg.topic = "insert into ctesting (data1) values ('"+temp+"')";


return msg;

Open in new window

db.png
0
I try to parse a JSON file from Java-script (nodes) generated with php. This JSON file has a very depth structure.
As sample:

{
  "application": {
    "title": "Korpuskonfigurator",
    "cart": "Projektverwaltung",
    "nyi": "Noch nicht verfügbar!",
    "dialogs": {
      "username": "Username",
      "id": "ID",
      "name": "Korpusname",
      "errors": {
        "missingFields": "Bitte alle Felder ausfüllen.",
        "specialCharacters": "Keine Sonderzeichen erlaubt!"
      }
    },
    "inspector": {
      "stowageHeight": "Stauhöhe",
      "newValue": "Neuer Wert",
      "firstDrilling": "Erste Bohrung",
      "original": "Original",
      "openOPC": "Ändern",
      "positions": "Positionen",
      "finalPosition": "Final",
      "corrPosition": "Korrekturwert",
      "origPosition": "Originalwert",
      "suggestedPosition": "Vorschlagswert",
      "delta": "Delta"
    },
    "helpmenu": {
      "minz": "Min. Z",
      "maxz": "Max. Z",
      "fov": "Blickfeld"
    }
}

Open in new window


How I can parse this JSON with php So will get for all data the full parameter and value.
As sample:

application.dialogs.errors.specialCharacters = "Keine Sonderzeichen erlaubt!"

Open in new window


So far I have:
$jsonfile = getcwd()."/import/translation_de.json";

$json = file_get_contents($jsonfile);

//Decode JSON
$json_data = json_decode($json,true);

foreach ($json_data as $key1 => $value1) {
    echo $json_data[$key1];
}

Open in new window


But this will fail.
0
I am pulling my hair out on parsing a JSON API response (from ShipStation) due to the arrays within the response object.  I have always used a JSON parser (from demon.tw) which works perfectly for accessing the various items in a JSON object, however it does NOT work with arrays because of the fact that it is using JScript one cannot loop with a variable index.

I have tried a few other JSON classes but still had no success in being able to easily loop through each order and pull the relevant order information for each.

Below is a sample of the JSON response from the API. Can someone please help me loop through the orders (only 2 orders in the array in the sample below), and populate all the necessary order variables on each loop, such as OrderID, Customer info, billing/shipping addresses, line items ordered, priciing etc.


Open in new window

0
Jasonstring = '{
"action":"Add",
"action2":"Adddelete",
"Data":[{"Age":35,"Name":"Name1"},{"Age":25,"Name":"Name2"},{"Age":30,"Name":"Name3"}}],
"Data_old":[{"Age":35,"Name":"Name1"},{"Age":25,"Name":"Name2"},{"Age":30,"Name":"Name3"}}]
}';

Using apex code from above Jason string how can I build jasonstring_new as below, I basically want to remove every other tag except action and data []

Jasonstring_new = '{
"action":"Add",
"Data":[{"Age":35,"Name":"Name1"},{"Age":25,"Name":"Name2"},{"Age":30,"Name":"Name3"}}],
}';
0
I have a job that I would like to get bids on...if that still happens on this site.  Here is what I need:

I need this page (https://www.gopherstateevents.com/results/fitness_events/results.asp?event_type=5&event_id=825&race_id=1427) to "scroll" vertically in marquee fashion for large screen display at races.  All I really need is the data table...or the data in the data table...to be visible.  Please let me know if you would be able to help me and what it would cost me.  I have tried to get this going in the "normal" process of doing it myself with EE help but, due to my weakness in JQuery, I just haven't gotten there.

Let me know if you have questions or if you can help me.
0
I need to convert the CURL POST command below to vba (access).  I'm very proficient with access vba but not anything web-based so any direction on learning materials would be also appreciated.  I found and modified an example that I thought might work (code below), but it just gives the error "ActiveX can't create the object.  Suggestions?

CURL COMMAND:
curl -X POST -H "Content-type: application/json" -H "Accept: application/json" -d '{"shop": "9999999999","client_code": "88888888888.","lastname": "Ender","phonenumber": "5555555559","vehicle_year": "1999","vehicle_make": "JEEP","vehicle_model": "something" }' http://somewebsite.com/api/customers

VBA CODE (Fails with error above):

Private Sub cmdCreateAutoTextCustomer_Click()
Dim sURL As String, sHTML As String
Dim oHttp As Object
Dim Body As String
'‘Add a reference to the MSXML type library
Set oHttp = CreateObject("MSXML3.ServerXMLHTTP")

'‘The website to post to
sURL = "http://somewebsite.com/api/customers"

'‘ The json string to send.
Body = "{""shop_number"": ""9729925026"",""client_code"": ""142KukK231k."",""lastname"": ""Ender"",""phonenumber"": ""5555555559"",""vehicle_year"": ""2009"",""vehicle_make"": ""JEEP"",""vehicle_model"": ""something"" }"

oHttp.Open "POST", sURL, False
oHttp.setRequestHeader ' "Content - type", "application / json" '
oHttp.setRequestHeader '"Accept”, "application / json"'

'‘Send the json
oHttp.send (Body)

'‘Server response.
sHTML = oHttp.responseText

0
For the json request ,
1. Match the key with a merchantUniqueIdentifier (key) in the request,
2. If the key matches then match the value extracted from a custom attribute.

Please find the attachment for the same. It has the request payload and the mid which needs to be verified.
Request.pdf
0
Hi,

I have the following XML after converting from JSON to XML :

<json>
  <metadata>
    <result>1</result>
    <reason>Zone Serialized</reason>
    <version>1</version>
    <command>dumpzone</command>
  </metadata>
  <data>
    <zone>
      <record>
        <ttl>86400</ttl>
        <Line>1</Line>
        <type>:RAW</type>
        <raw>; cPanel first:11.36.1.5 (update_time):1535217363 Cpanel::ZoneFile::VERSION:1.3 hostname:main.internet-webhosting.com latest:74.0.6</raw>
      </record>
      <record>
        <type>:RAW</type>
        <Line>2</Line>
        <ttl>86400</ttl>
        <raw>; Zone file for 170.26.8.103.in-addr.arpa</raw>
      </record>
      <record>
        <ttl>14400</ttl>
        <Line>3</Line>
        <type>$TTL</type>
      </record>
      <record>
        <name>170.26.8.103.in-addr.arpa.</name>
        <serial>2013042202</serial>
        <Line>4</Line>
        <ttl>86400</ttl>
        <expire>3600000</expire>
        <type>SOA</type>
        <retry>7200</retry>
        <class>IN</class>
        <refresh>86400</refresh>
        <mname>cns1.internet-webhosting.com</mname>
        <minimum>86400</minimum>
        <rname>report.internet-webhosting.com</rname>
        <Lines>6</Lines>
      </record>
      <record>
        <raw />
        <type>:RAW</type>
        <Line>10</Line>
        <ttl>86400</ttl>
      </record>
      <record>
        <nsdname>cns1.internet-webhosting.com</nsdname>
        <name>170.26.8.103.in-addr.arpa.</name>
        

Open in new window

0
I am storing image names in an array from DB and then encode it with json encode function to receive it in my ajax success method:

Here is the code"

$sql_gallery = "SELECT * FROM map_projects_gallery ";		
$gallery_result = mysqli_query($conn, $sql_gallery);
while( $gallery_row = mysqli_fetch_assoc($gallery_result) )
{					
$gallery_image_name[] = $gallery_row["img_name"];			
}		

echo json_encode(array("map_gallery" =>$gallery_image_name ));		

Open in new window



Note: In ajax success function it returns all the image names. Now I want to display all images in a div and then later display them in a slider.


And here is my Code of jQuery Ajax
jQuery.ajax({
	url:"project.php",
	type: "POST",	
	data:  {"country_id":country_id,"lang_name":langname_val,"node_id":node_id,"fullurl":'<?php echo base_path();?>'},
	dataType: "json",								
	success: function(data)
	{
		alert(data.map_gallery);
		jQuery('#project-list').html(data.message1);  
	        jQuery('#paginations').html(data.message_2); 
		  
		
		  ///jQuery('.pr-cont-gallery').html('<img src=files/'+project_details.project_image+' width=200px>');	  
		  
		  jQuery('.pr-cont-gallery').append('<img src="' + data[0].map_gallery + '" />');

		  
		  data.forEach(function (data) {
				jQuery('.pr-cont-gallery').append('<img src="aaaaa.jpg" />');
		   });
	},
  }); 

Open in new window


Problem:  I am unable to display all images separately in a div. Need help to fix this issue
0
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.

Hi Experts,

Can anyone tell me why my loop at the end of the script is not executed? I think something to do with length?

function translate(){
    
    var lbls = {
        'logo' : {
            'selector' : '',
            'english' : '',
            'ta' : '',
            'zh' : ''
        } ,
        'office' : {
            'selector' : '.footer-contact-detail-section '
                       + '.col-md-4:nth-child(1) h6',
            'prop' : 'text',
            'english' : 'Office',
            'ta' : 'Office_ta',
            'zh' : 'Office_ma'
        } ,
        'cell' : {
            'selector' : '.footer-contact-detail-section '
                       + '.col-md-4:nth-child(1) h4',
            'prop' : 'text',
            'english' : 'Cell',
            'ta' : 'Cell_ta',
            'zh' : 'Cell_ma'
        } ,
        'book' : {
            'selector' : '.footer-contact-detail-section '
                       + '.col-md-4:nth-child(3) h4 a',
            'prop' : 'text',
            'english' : 'Book 30 mins <br> FREE consultation',
            'ta' : 'Book <br> ta',
            'zh' : 'Book <br> ma'
        }
    };
    
    var lang = jq('#lang_choice_polylang-2').val();
        
    if (lang !== 'en'){
        
        var i;
        for (i = 0; i < lbls.length; i++){
            if (lbls[i]['prop'] === 'text'){
                console.log(lbls[i][lang]);
            }
        }
    }
    
}

Open in new window

0
Hi,

I would like to get help with converting from vb.net to json. I need to have classes and conversion to be in this format once it's been serialized:
{
  "Employee": {
    "EmployeeId": "9978",
    "PersonalIdentityNumber": "19730222-9989",
    "FirstName": "Karin",
    "LastName": "Brovall",
    "FullName": "Karin Brovall",
    "Address1": "",
    "Address2": "Båtsmansvägen 7",
    "PostCode": "441 50",
    "City": "ALINGSÅS",
    "Country": "",
    "Phone1": "0322-36844",
    "Phone2": "",
    "Email": "",
    "EmploymentDate": "1997-10-01",
    "EmploymentForm": "TV",
    "SalaryForm": "TIM",
    "JobTitle": "Försäljning",
    "PersonelType": "ARB",
    "ScheduleId": "HEL",
    "ForaType": "-",
    "MonthlySalary": 0,
    "HourlyPay": 125,
    "TaxAllowance": "TMP",
    "TaxTable": 34,
    "TaxColumn": 1,
    "NonRecurringTax": 30,
    "Inactive": false,
    "ClearingNo": "", 
    "BankAccountNo": ""
  }
}

Open in new window


For this reason I used json utils to convert to classes and got this result:
    Public Class Employee
        Public Property EmployeeId As String
        Public Property PersonalIdentityNumber As String
        Public Property FirstName As String
        Public Property LastName As String
        Public Property FullName As String
        Public Property Address1 As String
        Public Property Address2 As String
        Public Property PostCode As String
        Public Property City As String
        Public Property Country As String
   

Open in new window

0
Total noob here, trying to ramp up knowledge to replace somebody at work who's leaving... In a Symfony 2 controller I am trying to add a public function (a SQL query) from the DB.php file. It will output to a JSON response. The IDE shows an error, which I'm sure is because I don't have all the needed info in there. What else do I need? Please see attached pic.
2018-08-11_15-04-11.jpg
0
I have the following json:
{
"count":2,
"page":1,
"pageSize":2,
"students":[{"forename":"Joe","surname":"Bloggs"},{"forename":"John","surname":"Doe"}],
"totalCount":2,
"totalPages":1
}

Open in new window


How can I alter this in PHP to just get the following:
{
[{"forename":"Joe","surname":"Bloggs"},{"forename":"John","surname":"Doe"}]
}

Open in new window


Thank you in advance
0
This question will likely expose my level of understanding of JQuery but I am getting this error:

Uncaught TypeError: $(...).marquee is not a function
    at results_scrollx.asp?event_type=5&event_id=794&race_id=1382:62

On this page: https://www.gopherstateevents.com/results/fitness_events/results_scrollx.asp?event_type=5&event_id=794&race_id=1382

I assume there is something structurally wrong but I haven't found it yet...  Any help would be much appreciated.
0
Trying to get the values of Json Array isnt working.

for(var i = 0; i < testjson.TYPE_ID.length; i++){
            if(testjson.TYPE_ID[i]) {count += 1;}
        }

Open in new window


"TYPE_ID":["pinterest","vimeo","gravatar","twitter","linkedin","klout","facebook","flickr","foursquare"] . this is the Json here which im trying to pull all these arrays and check for one of them to output a response.

using JQ, JS
0

JSON

771

Solutions

767

Contributors

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