JSON

584

Solutions

613

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

Hi folks,

I have a piece of code that is trying to read out member details from a file and then use a date in that file together with today's date to work out the approximate difference in months (I have not yet started to tackle the exact days in a given month yet) and see if they are over 12 months therefore I can class them as an 'overdue' payment.

I have tried a number of different ways and seem to end up looping around back to TypeError: an integer is required (got type str).

I have attached a cut down version with just the part of the code with an error. I think the issues is within these following lines however I could be wrong:

d = datetime.datetime.now()

lastdatepaid = int(datetime.datetime("%Y-%m-%d"))

newldp = datetime.datetime.strptime(lastdatepaid,"%Y-%m-%d").date()

datechange =(d - lastdatepaid).days

It might help to have the JSON file data:

[[{"DOB:": "2001-11-17", "FeeType:": "SP", "Firstname:": "Joe", "Last Date Paid:": "2016-11-01", "Money Owed: \u00a3": 100, "Months Overdue:": 0, "Months til Overdue:": 12, "Surname:": "Bloggs", "Times Overdue:": 1}]]

N.B. Not all aspects of the project are fully completed but this is my biggest problem I have not been able to solve.

Thank you very much in advance for you help.
Cut-down-version.py
0
How to Use the Help Bell
LVL 11
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

I have this json output.
var jsonstr = "{\"formattedResults\":{\"ruleResults\":{\"MinimizeRenderBlockingResources\":{\"localizedRuleName\":\"Eliminate render-blocking JavaScript and CSS in above-the-fold content\",\"ruleImpact\":12.0,\"groups\":[\"SPEED\"],\"summary\":{\"format\":\"Your page has {{NUM_SCRIPTS}} blocking script resources and {{NUM_CSS}} blocking CSS resources. This causes a delay in rendering your page.\",\"args\":[{\"type\":\"INT_LITERAL\",\"key\":\"NUM_SCRIPTS\",\"value\":\"1\"},{\"type\":\"INT_LITERAL\",\"key\":\"NUM_CSS\",\"value\":\"3\"}]},\"urlBlocks\":[{\"header\":{\"format\":\"None of the above-the-fold content on your page could be rendered without waiting for the following resources to load. Try to defer or asynchronously load blocking resources, or inline the critical portions of those resources directly in the HTML.\"}},{\"header\":{\"format\":\"{{BEGIN_LINK}}Remove render-blocking JavaScript{{END_LINK}}:\",\"args\":[{\"type\":\"HYPERLINK\",\"key\":\"LINK\",\"value\":\"https://developers.google.com/speed/docs/insights/BlockingJS\"}]},\"urls\":[{\"result\":{\"format\":\"{{URL}}\",\"args\":[{\"type\":\"URL\",\"key\":\"URL\",\"value\":\"value 1 output\"}]}}]},{\"header\":{\"format\":\"{{BEGIN_LINK}}Optimize CSS Delivery{{END_LINK}} of the 

Open in new window

0
Hi,

I am in the process of building a call to a rest service.  I am correctly making the calls to the service etc, but I am having a slight issue with pulling specific data out.

Given the below response:

"{"nextpageuri":null,
"previouspageuri":null,
"sms_messages":
[{"created":"Fri, 08 Dec 2017 03:34:55 +0000",
"id":"cf4083fd852758af8bca5cffb77771d7",
"from":"0419000000","destination":"61417000000",
"message":"SAMPLE MSG",
"uri":"\/2016-11-30\/sms\/cf4083fd852758af8bca5cffb77771d7",
"receipts":{"delivered":"Fri, 08 Dec 2017 03:34:58 +0000"}}],"message":"Response follows","api_version":"2016-11-30","status":200,"uri":"\/2016-11-30\/sms\/cf4083fd852758af8bca5cffb77771d7"}"

Open in new window


This is what I am attempting to use to seperate out the receipts:
  // MAKE AN OBJECT
$Callresult = json_decode($response);
echo "attempt 1:".$response->sms_messages[0]->receipts;

But I keep getting an error of:
Notice:  Trying to get property of non-object

and if I try:
echo "attempt 1:".$response->sms_messages[0]->receipts;
i get:
Catchable fatal error:  Object of class stdClass could not be converted to string

if anyone could help it would be most appreciated!!!
0
hello,
how can pass array value in postman.
option={"227":"19","228":"24"}
0
I have a Google Sheet with responses from a questionnaire to several people. One question was Post Code, so I now have a Map in Google Fusion Tables showing where they're all located according to Post Code.  That's all working fine, but my question is about the Info Window.  I've customized that to a certain extent, so now it only shows the fields that I want. But what I want to do is...

a) For some fields (checkboxes), only show it and associated data if the data is non-empty.

b) For other fields (multiple choice grid where the left column of the grid is 'None'), only show it and associated data if the data is NOT EQUAL to 'None'.

I've searched a lot in forums about this, and I've found many answers that use 'if' statements, but I can't get anything to work. Every time I use the curly brackets {} it thinks I'm trying to specify a column name, so I get 'Unrecognized column' every time I try using {if ...} or {template .contents}, or anything apart from {a name of one of my columns}.

Also, I've seen a lot of references to $data.value.name - but nothing that explains how I modify this to include the actual name of my column.

First of all, since (b) should be simpler, could you help me with that one first?

Thanks.
0
<script>

         $(document).ready(function()  {
                    $('#importSubmit').on('click',function(){
                    var phone1=document.getElementById('phone').value;
                    //alert(phone1);
                    var msg=document.getElementById("message").value;
                    // alert(msg);
                    var opt=document.getElementById("opt").value;
                    //alert(opt);
                    var impt=document.getElementById("importSubmit").value;
                    //alert(impt);
   
                   
                    $.ajax({

                    type: 'GET',

                    url: 'http://localhost/whatsapp_message_sender/importData.php?',

                    dataType: "json",
                     //data:'foo='+ bar+'&calibri='+ nolibri,
                    data: 'importSubmit='+impt+'&phone=' +phone1+'&message='+msg+'&opt='+opt,    

                    success: function(data){
                    //alert(data);
                    $('#lkct').html(data);
                   

                                              },
                error: function(jqXHR, textStatus, errorThrown)

                {

                  alert("Error: "+errorThrown+" , Please try again");  

                }      

      });

        });
});
   //});
</script>


where I went wrong here  I'm getting this error  please help me to solve problem
0
MENU DROP DOWN LIST WITH CHECKBOX in ANGULAR 4 ...... the Menu data should be offline JSON
0
Hello Experts,
Any safe Windows application or plugin to convert a CSV file to JSON. Please note I cannot use solutions online as I am handling confidential data and cannot upload it. Appreciate any suggestions.
0
how to post the ANGULAR 4 Form DATA in Offline JSON..
0
I would like to get multiple Json outputs of multiple iperf3 tests to a single file and plot be able to do graphing on it.
0
Keep up with what's happening at Experts Exchange!
LVL 11
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Hi,
I want to populate data into the model from inside a controller.
Suppose there is a controller method  fetchResponse(Task task) That takes some Task object...
and returns a json TaskResponse object.

now here could be one implementation :

fetchResponse(Task task  @(RequestParam))
{

TaskResponse taskResponse = new TaskResponse(task);
return serialize taskResponse.
}

TaskResponse {

attributes.
.
.
.
TaskResponse(Task task)
{
populate attributes
}

This is one way in which all the attributes of the TaskResponse object will be filled inside the TaskResponse object which will be serialized and sent .

Please suggest any pros and cons of this aproach... Also any alternatives.

Thanks
0
I'm looking to make a specific graph layout from a specific **format** of **Python** data, but where the **data may be text, string, or another Python object**.

It has to be able to do it on the **fly**, and make visual formatting decisions based on whether the data is "the same" (regardless of numerically, text or another Python object).

It doesn't matter if Excel is used to make the image (*.xls or .csv) or ```matplotlib```or anything else.

***The coloring in the cells*** is based on whether the items within ```{1:"A", 2:"A"}```are **equivalent** (not the same object). **Green** for ```True```, **red** for ```False```. For example: ```"A" == "A"``` (as in the preceding sentences), or ```(10/5) == (20/10)```, or ```["A", 1, <test object at 0x1052c9b70>] == ["A", 1, <test object at 0x1052c9b70>]``` would all be green.

The text that appears in the cells is just the \__str__ representation of the object.

EDIT: I'm not so much looking for someone to do the work for me, but a recommendation of which tool (```XLS```, ```matplotlib```, ```whathaveyou```) would be best suited - and maybe a link to a tutorial on how to do some of those more difficult features (like the cell coloring).

I.e. ...
   
    {
        1000:{
              "Sample1":{1:"A", 2:"A"},
              "Sample2":{1:"A", 2:"A"},
              "Sample3":{1:"A", 2:"A"},
              },

        1001:{
              "Sample1":{1:"A", 2:"A"},
              "Sample2":{1:"A", 2:"A"},…
0
I am currently developing a credit check app which uses web services and the response I get is in Json string format. I tried converting this to a Json object... however I was unsuccessful. I need to store this json result into an excel document. The json result is in the following format after desterilizing:

[
{
"Key": "CreditResult",
"Value": [
[
{
"Key": "ConsumerInfo",
"Value": {
"RecordSeq": "01",
"Part": "001",
"PartSeq": "01",
"ConsumerNo": "943599475",
"Surname": "TEST SURNAME",
"Forename1": "TEST NAME",
"Forename2": "",
"Forename3": "",
"Title": "MS",
"Gender": "F",
"NameInfoDate": "20170129",
"DateOfBirth": "20170101",
"IdentityNo1": "1234567891234",
"IdentityNo2": "",
"MaritalStatusCode": "",
"MaritalStatusDesc": "",
"Dependants": "00",
"SpouseName1": "",
"SpouseName2": "",
"TelephoneNumbers": "H(000)0000000 B(0000)0000",
"DeceasedDate": "00000000"
}
},
{
"Key": "LastAddress",
"Value": {
"ConsumerNo": "943599475",
"InformationDate": "20170911",
"Line1": "ABC",
"Line2": "",
"Suburb": "ABC",
"City": "ABC",
"PostalCode": "0000",
"ProvinceCode": "A",
"Province": "ABC",
"AddressPeriod": "00",
"OwnerTenant": "",
"AddressChanged": "Y"
}
}
],
[
{
"Key": "CreditScore",
"Value": {
"ConsumerNo": "943599475",
"PolicyFilters": [
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0"
],
"Indicators": [
{
"Type": "00",
"Score": "000"
},
{
"Type": "00",
"Score": "0"
},
{
"Type":…
0
hi,
i am looking for json web tokens end to end example using java. can you please advise
0
I wanted to parse a binary value and store it in a blob column in a database.
Input is a JSON format,


I have tried using the below code, I am getting error (Invalid LOB Locator) on the below line

DBMS_LOB.CONVERTTOCLOB ......
 

Below is my anonymous block used in apex rest service.

DECLARE
L_PROFILE_X BLOB;
--Can only read body once as BLOB (this package assumes a base 64 encoded string)
v_body_blob_1 BLOB ;
v_body_blob_test BLOB ;
--BLOB for binary image and CLOB for base 64 encoded
v_image_blob_1 BLOB;
v_clob_1 CLOB;

--CLOB Conversion Parameters
l_src_offset_1 NUMBER := 1;
l_dest_offset_1 NUMBER := 1;
l_blob_csid_1 NUMBER := DBMS_LOB.DEFAULT_CSID;
l_lang_context_1 NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
l_warning_1 NUMBER;
l_amount_1 NUMBER;



--Can only read body once as BLOB (this package assumes a base 64 encoded string)
v_body_blob_2 BLOB ;

--BLOB for binary image and CLOB for base 64 encoded
v_image_blob_2 BLOB;
v_clob_2 CLOB;

--CLOB Conversion Parameters
l_src_offset_2 NUMBER := 1;
l_dest_offset_2 NUMBER := 1;
l_blob_csid_2 NUMBER := DBMS_LOB.DEFAULT_CSID;
l_lang_context_2 NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
l_warning_2 NUMBER;
l_amount_2 NUMBER;

 
BEGIN

L_PROFILE_X := :body;

for i in 
(SELECT id,hosted_by,episode_guest,link,go_live_description,logo_image,mime_type_logo,bg,mime_type_bg
 FROM json_table
 (L_PROFILE_X , '$' 
  COLUMNS 
  (id  NUMBER FORMAT JSON  PATH '$.id',
   hosted_by  NUMBER FORMAT JSON PATH '$.hosted_by',
   

Open in new window

0
Hi,

From what I know, if you are documenting a data structure (e.g. JSON) with embedded objects, you might have something like this for the data schema tables:

DISCLAIMER: In the real world, I doubt you'd have a full (e.g.) doctor object embedded in the prescription object. More likely, you'd have a record number for patient, doctor, drug, but the below is useful for this example. :)

PRESCRIPTION OBJECT
Date
Time
Rx Number
Patient Object
Doctor Object
Drug Object
Directions
etc.


You'd then have tables for the aforementioned objects, which themselves could contain objects:
DOCTOR OBJECT
LastName
FirstName
IdNumbers Object
Address
etc.

And in turn...
ID NUMBERS OBJECT
Licence
DEA
NPI
-----------
Now, to the question. I'm documenting an API where some of the embedded objects contain only one field/object. To use the above example, something like:

PRESCRIPTION OBJECT (as before: contains many fields/objects)

DOCTOR OBJECT (Contains one object)
IdNumbers Object

ID NUMBERS OBJECT (Contains one field)
License

Per the above, would I be overdoing it to have separate data tables for these objects containing only one field/object? If so, I'd need to find a clean way to embed everything in the parent table.

Thanks!
Steve
0
I have the code, where I load data from a csv file and the data is obtained by using D3 nest.

The code I wrote is:
 d3.csv("data/data2.csv", function(data1) {      

                  var workStation = 
                                {"key":"Data","values":
                                d3.nest()
                                .key(function(d) { return d.WorkStation_Id; })
                                .key(function(d) { return d.Order_Id; })
                                .rollup(function(v) {
                                    return v.map(function(c){
                                        return { "actualStart": convertscheduledtime(c.ScheduledTime),"rowHeight": 30, "actualEnd":c.Duration*1000+convertscheduledtime(c.ScheduledTime), "name":c.Order_Id};
                                    });
                                }).entries(data1)};

                var d2= [{"name":"Data", "children":workStation.values.map( function(major){  
                        return {
                            "name": major.key,
                            "children":major.values.map( function(Order_Id){
                                return{
                                    "name" : Order_Id.key,
                                    "actualStart" : Order_Id.values.actualStart,
                                    "actualEnd" : Order_Id.values.actualEnd
                                };
                            })
                            };
                 

Open in new window

0
I have a project with a TON of DLL's in the Bin Directory.

One of the DLL's used is NewtonSoft JSon

several of the other DLL's reference it but one or more require a (lower) version of the NewtonSoft

Is there a way to determine which ones are dependent on NewtonSoft AND what version they are requireing?
0
Hi expert

I have found a picture on the internet and modified little bit. I would like to implement the same things on my AWS environment.

Is there anyone who can help me to create a template so that i can imported directly. I am having issue in designing the same diagram

I have attached the cloud formation diagram. Please follow the attach file
Network-Diagram.docx
0
Free Tool: IP Lookup
LVL 11
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Good Day Experts!

I am.Net developer enrolled in a web development boot camp. I have some functionality to create that I am not well versed in.  I need to display images that are clickable.  When clicked on, I need to perform some tasks.  After that, re-display the images in a different order.  I have a JSON file with the image URLs.

Do you have any good reference material suggestions to help me with my project?

Thanks,
jimbo99999
JSON.txt
0
I can retrieve the JSON data without a problem, except that data between the second level of [] is missing.  If i retrieve the file in a browser and inspect source, all of the data is there.  But in VBA, the characters inside the first level of [] but all of the data in the second level is missing, leaving just the [ ].

I thought responsetext from the http get would be just that: text.  Its not that the text is too long.  There is lots of other text in the response.  But for every variable array (ie second level [ ]), the data is missing.

I working with Yahoo stocks/options: for example: https://query1.finance.yahoo.com/v7/finance/options/rh
and the response is a well-formed JSON but VBA does not provide and of the expirationDates or strikes.

What am I missing?
0
Hi,

I had a problem with a content from urls like below. I need to extract json code from the url below and decode and then use it.
Unfortunately it was invalid json. json_decode returning null. I want complete part of html : "<div... from the url and save it as html file.


$url = "http://content-preview.webcollage.net/epartner/view-ppp?environment-id=live&module=axe&partner=epartner&wcpc=1492543619127&is-secured=false&format=js";

$unparsed_json = file_get_contents($url);
		$test = json_decode($unparsed_json);
		if(json_last_error()=== "JSON_ERROR_NONE")
		{
			echo "no errors";
		}
		else {
			echo json_last_error_msg();
		}

Open in new window

output: Json syntax error
0
Hi,

I know I have to use json_decode, but I am having a few issues getting to the id (i bolded the value I want.
{"message":"Request submitted","sms":[{"destination":"61402XXXXXX","from":"XXXXXXXXXX","id":"d3c2183dbbb9895386ffd3d234f90421","receipts":{},"message":"Hi, Please contact CCC","uri":"\/2016-11-30\/sms\/d3c2183dbbb9895386ffd3d234f90421","created":"Fri, 01 Dec 2017 11:31:14 +0000"}],"api_version":"2016-11-30","status":200,"uri":"\/2016-11-30\/sms"}

This is what I have so far, but none of it is really effective.
$Callresult = json_decode($response);
$Callresult2 = json_decode($response,True);
echo "<br><Br>Call Result <br><br>";
var_dump($Callresult);
echo "<br><Br>Call Result 2<br><br>";
var_dump($Callresult2);
echo "<br><Br>Message: ";
echo $Callresult2->message."<br><br>";
//print_r($Callresult);
//echo("<br><Br>Status Testing: <Br><br>");
//$xmlresult = "";
$Callresult = $Callresult;
echo "<br><br>Response1:".$Callresult;
echo "<br><br>";
$Callstatus = $Callresult[0]->id;
echo "<br><br>Response2:".$Callstatus;

is anyone able to assist?
0
Java JSON Encode using Map

Let's see a simple example to encode JSON object using map in java.

import java.util.HashMap;  
import java.util.Map;  
import org.json.simple.JSONValue;  
public class JsonExample2{    
public static void main(String args[]){    
  Map obj=new HashMap();    
  obj.put("name","sonoo");    
  obj.put("age",new Integer(27));    
  obj.put("salary",new Double(600000));   
  String jsonText = JSONValue.toJSONString(obj);  
  System.out.print(jsonText);  
}}    
Output:

{"name":"sonoo","salary":600000.0,"age":27}
Java JSON Array Encode

Let's see a simple example to encode JSON array in java.

import org.json.simple.JSONArray;  
public class JsonExample1{    
public static void main(String args[]){    
  JSONArray arr = new JSONArray();  
  arr.add("sonoo");    
  arr.add(new Integer(27));    
  arr.add(new Double(600000));   
  System.out.print(arr);  
}}    
Output:

["sonoo",27,600000.0]
Java JSON Array Encode using List

Let's see a simple example to encode JSON array using List in java.

import java.util.ArrayList;  
import java.util.List;  
import org.json.simple.JSONValue;  
public class JsonExample1{    
public static void main(String args[]){    
  List arr = new ArrayList();  
  arr.add("sonoo");    
  arr.add(new Integer(27));    
  arr.add(new Double(600000));   
  String jsonText = JSONValue.toJSONString(arr);  
  System.out.print(jsonText);  
}}    
Output:

["sonoo",27,600000.0]

Open in new window


what is meaning of encode?

what is difference of above 3 programs and outputs?

output1 from Java JSON Encode using Map is
{"name":"sonoo","salary":600000.0,"age":27}(why brackets are { } unlike [] etc??)

output2 from Java JSON Array Encode is
["sonoo",27,600000.0](why square brackets here??)

output3 from Java JSON Array Encode using List is
sonoo 600000.0 27 (why no brackets here??)
0
<!DOCTYPE html>
<html>
<body>

<h2>JSONStringFromJavaScriptObjectUsingStringfy_7</h2>

<p id="demo"></p>

<script>

var obj = { "name":"Gary", "age":30, "city":"New York"};
var myJSON = JSON.stringify(obj);
document.getElementById("demo").innerHTML = myJSON;

</script>

</body>
</html>

Open in new window


i am looking at above example

what is java script object there ?

is below is java script object?
var obj = { "name":"Gary", "age":30, "city":"New York"};
or above is json object? or we can call it as both?
please advise
0

JSON

584

Solutions

613

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