Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x

JSON

528

Solutions

568

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

Hello Experts

I am getting a json response from a URL which I am trying parse it and capture code to store in the DB

Its returning the string ok but I am unable to remove the quoted strings to save the code in the DB
 

 Dim jResults As Object = JObject.Parse(Json)
        Dim jsonResulttodict = JsonConvert.DeserializeObject(Of Dictionary(Of String, Object))(Json)
        Dim firstItem = jsonResulttodict.Item("error")
        Dim seconditem = jsonResulttodict.Item("success")
        Dim thirditem = jsonResulttodict.Item("codes")

example string:

'{"error":"","success":"1 code generated successfully","codes":["QTESTA2HLT"]}


I am getting the code as [{  "QTESTA2HLT"  }]

Al I want is to read as QTESTA2HLT

please advise

thanks
0
Free Tool: IP Lookup
LVL 10
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.

Hi ,

I am creating a simple component in Angular 4

-my-account  // angular project folder
--app
----account  // angular component folder
-----css
-----js
-----images
-----account.component.html

//css , js , images are folders I created and put files.


Now I want to use css files from the above css folder in account.component.html.  How do I access ?


Here is my non working code

account.component.html
----------
<head>
 <Link href="css/datatables.min.css" rel="stylesheet" type="text/css"/>
 ....
 </head>
 
 
 I'm getting error
 zone.js:2744 GET http://localhost:4200/css/datatables.min.css 404 (Not Found)

please note this file is already present in css folder.
 
Do you have any suggestion how to access css files in component html   ?  what is the proper way to fix ths issue ?
Need help
1
I am trying to deserialize a string:

[{"balance":239443915909,"pendingFunds":0,"currency":"XRP"},{"balance":37185679,"pendingFunds":0,"currency":"BCH"},{"balance":0,"pendingFunds":0,"currency":"ETC"},{"balance":247,"pendingFunds":0,"currency":"AUD"},{"balance":0,"pendingFunds":0,"currency":"USD"},{"balance":0,"pendingFunds":0,"currency":"BTC"},{"balance":0,"pendingFunds":0,"currency":"LTC"},{"balance":126133303,"pendingFunds":0,"currency":"ETH"},{"balance":0,"pendingFunds":0,"currency":"FCT"},{"balance":0,"pendingFunds":0,"currency":"MAID"},{"balance":0,"pendingFunds":0,"currency":"DAO"}]

But it errors

Error
The code I am using is
private void startToolStripMenuItem_Click(object sender, EventArgs e)
        {
           string bal = RetrieveAccountBalance();
            AccountDetail Details = JsonConvert.DeserializeObject<AccountDetail>(bal);
        }
       #region Account Methods

 public class AccountList
        {
            public List<AccountDetail> data { get; set; }
        }

        public class AccountDetail
        {
            public string balance { get; set; }
            public string pendingFunds { get; set; }
            public string currency { get; set; }
        }

Open in new window


Could anyone help with this error
0
A 3rd party provider is sending json back to me in this format.

{"specified_lists":["xxxx","yyyy","zzzz","wwww"],"key":"123456789","found":false}

When I execute $json = json_decode($response,true); the last value is not being picked up. How do I read the false statement at the end?

I can get the value of key by using $key = $json->key; but found won't show it's value.
0
Python Gurus--

I am utilizing a 3rd-party API which returns the data I'm looking for in JSON--however, there is a u'foo' in front of everthing. Maybe a unicode thing?  I want to extract the elements to toss into a tabe that has the same element names.

Here's what I am getting:

[{u'comment': u'', u'enableSpeedWarning': False, u'major': 17, u'licensePlate': u'', u'enableMustReprogram': False, u'immobilizeArming': 30, u'engineVehicleIdentificationNumber': u'1XPBDP9X3GD301269', u'isActiveTrackingEnabled': False, u'workTime': u'WorkTimeStandardHoursId', u'isReverseDetectOn': False, u'brakingWarningThreshold': -34, u'gpsOffDelay': 10, u'minAccidentSpeed': 3.0, u'serialNumber': u'G7DF20DBD6F6', u'timeToDownload': u'1.00:00:00', u'maxSecondsBetweenLogs': 200.0, u'isSpeedIndicator': False, u'id': u'b18', u'customParameters': [], u'hardwareId': 551278326, u'name': u'1579', u'activeFrom': datetime.datetime(2017, 7, 31, 18, 13, 27, 296000, tzinfo=<UTC>), u'corneringWarningThreshold': 26, u'deviceType': u'GO7', u'disableBuzzer': False, u'accelerometerThresholdWarningFactor': 0, u'speedingOff': 90.0, u'minor': 59, u'productId': 109, u'odometerOffset': 0, u'isDriverSeatbeltWarningOn': False, u'deviceFlags': {u'isGarminAllowed': True, u'isOdometerAllowed': True, u'isTripDetailAllowed': True, u'isIridiumAllowed': True, u'isEngineAllowed': True, u'isVINAllowed': True, u'activeFeatures': [], u'ratePlans': [], u'isActiveTrackingAllowed': True, u'isUIAllowed': True, u'isHOSAllowed': …
0
I'm looking to consume an external Rest API Json data source into a SharePoint Online list column. I have the enterprise version with BCS.  Anyone had luck with this?
0
I am trying to do something similar to the app specs below.  I'm looking for a sample.  I thought I would use Asp.net Core MVC,  Ajax and SQL server.  I'm looking for a sample that can show me each step.

It's pretty simple.
1. My app has a form with 4 fields. (Vin, Make, Model, Year)
2. I input Vin in field 1 (Vin)
3. I GET from a third party Rest API JSON by passing the Vin to a URI string. The string will pass Vin I input and an API key
4. The API returns (Make, Model, Year)
5. I want to fill the additional form fields with (Make, Model, Year)
6. Finally, I want to save all fields (Vin, Make, Model, Year), to my Database.

I have been searching for an example similar.  I did find the Weather app example, but it's not complete.  It's just part of it.
Weather example: https://www.codeproject.com/Articles/1180283/How-to-Implement-OpenWeatherMap-API-in-ASP-NET-MVC
0
I have been asked to do some work developing a WebAPI in .Net using VS 2017 and I have been asked to use JSON Web Tokens (JWT).  I plan on staying with the uniform interface but testing the header which will contain a JWT.  I realise that this test needs to happen in line with any GET, POST, PUT, OR DELETE request but prior to it happening.  I am staying close to MVC style of the convention but I don't know how to capture and test the JWT and authorise it.  I do know how to encrypt/construct and decrypt a token.  What I am specifically ignorant is the capture in process and testing to accept or reject any request.
0
Hello,

We have a JSON file that we are trying to read and put the Key and the values in a CSV file. We are getting an error as below. can someone please help?

Attached is the sample JSON file and the Python code we are using.

Our program Parse_workitem.py accepts 2 arguments one is  input_file which is json and the other one is output_file which is csv. When we execute the code as below with both arguments the code is failing with the following error. We are using Python version 2.7.5


./parse_workitem.py --input_file /home/dqadmin/json/work_items.json  --output_file /home/dqadmin/json/work_items.csv
Traceback (most recent call last):
  File "./parse_workitem.py", line 66, in <module>
    main()
  File "./parse_workitem.py", line 54, in main
    value = item.get(key, '')
AttributeError: 'unicode' object has no attribute 'get'


Thank you
parse_workitem.py
sample.txt
0
Hello,

I am trying to parse JSON file through JAVA program that has nested objects and arrays.

I am attaching the sample JSON file and the expected results.

I am also attaching the JAVA class program that I am currently using but it only prints the first object and the values related to it. I want the JAVA code to loop through each object and find the nested objects within it and print it as well.

import java.io.FileReader;
import java.util.Iterator;
import java.util.Set;

import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
 
/**
 * @author Crunchify.com
 */
 
public class CrunchifyJSONReadFromFile {
 
    @SuppressWarnings({ "rawtypes" })
    public static void main(String[] args) {
        JSONParser parser = new JSONParser();
 
        try {
 
            Object obj = parser.parse(new FileReader(
                    "/Users/username/Documents/Work_Items.json"));
            
        
            JSONObject jsonObject = (JSONObject) obj;
 
            Set keys = jsonObject.keySet();
            Iterator a = keys.iterator();
            while(a.hasNext()) {
            	String key = (String)a.next();
                // loop to get the dynamic key
                String value = (String)jsonObject.get(key).toString();
                System.out.println("key : "+key);
                System.out.println(" value :"+value);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Open in new window

Can someone please assist?

Thank you
sample.txt
Book2.xlsx
0
Monthly Recap
Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Hi,

My button don't work but alert work after success, what should I do ?


<!DOCTYPE html>
<html lang="fr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/gif" href="img/drapeauBruxelles.gif" />
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/style.css">
    <title>Projet Map</title>
    <style>
       #map {
        height: 600px;
        width: 90%;
       }
    </style>
  </head>
  <body>
    <div class="container-fluid bg-2 text-center">
      <h1 class="margin">Des Marqueurs Google Maps</h1>
    </div>
    <div id="map"></div>
    <nav class="navbar navbar-default">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="https://developers.google.com/maps/documentation/javascript/adding-a-google-map?hl=fr">My Google Maps</a>
        </div>
        <div class="collapse navbar-collapse" id="myNavbar">
          <ul class="nav navbar-nav navbar-right">

            <li><button type="button" id="btn1">Fontaine d'eau</button></li>
            <li><button type="button" onclick="actionImmediate();">Fontaine d'eau</button></li>
   

Open in new window

0
Hello Experts,

I'm totally new to programming using MVC in .net 4.5 and using (DB first) approach beside scaffolding way to create controllers and views from existing models.

I have 2 models:
1 - Agency Model: [AgencyID],[AgencyName],[AgencyCategoryID]
2 - AgencyCategory Model: [AgencyCategoryID],[AgencyCategoryName]
 
They are related based on "AgencyID" key.

I want to populate a dropdown list in "Agency view" using "AgencyCategoryID and  AgencyCategoryName" from
"AgencyCategory Model".

Please tell me how to do it step by step with an example.

Thanks a lot in advance.
Harreni
0
Hello,

I am trying to parse a JSON format data that is stored in oracle CLOB data column. There are multiple/nested objects in the JSON data so I need a query to automatically get all the object/parent name and the value related. Please see attached is the sample example of the JSON data  and the expected output.

I tried the below query but it only gives the value and not the object/Key name.

SELECT jt.*
FROM   JSON_DOCUMENT_lob a,
       JSON_TABLE(json_msg, '$."Additional Statement No".*'
         COLUMNS ( 
           "Attribute/Parent" varchar2(32000) PATH '$.parent()',
           "Value" varchar2(32000) PATH '$'
       )) "JT";

Open in new window


Please assist.

Thank you
SampleData.txt
Book2.xlsx
0
PS: This issue is only happening when i see result in swagger ui , i visual studio it looks fine.

I am trying to replace the string which i have

\\/Date(1430370000000+0530)\\/
to

\/Date(1430370000000+0530)\/
Code:

 string str = "\\/Date(1430370000000+0530)\\/";
 str = str.Replace(@"\","\\");          
 Console.WriteLine(str);
See here the code running environment, click here

Output i am getting above is this :

\/Date(1430370000000+0530)\/
But while we pass the value in JSON property.

The value automatically converts to below value

/Date(1430370000000+0530)\\/
But I am expecting the same value which I got earlier

\/Date(1430370000000+0530)\/
0
Hello - I am trying to figure out how to accomplish two items when working with HTML tables.

1). I want to have the results of the table limited based on user entry in a text box.

2) In addition...I want the results to be sorted based on the value of another field.

For example...for the data in the JSON file specified below...lets say the user has entered "Business Owner" into a text box on the website...I want the results to be limited to only that job...and I want the data sorted by the Roll field.

Where do I start in getting these items accomplished?

Here is the HTML code:

<!DOCTYPE html>
  <html>
      <head>
          <meta charset="utf-8">
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <title>Restatement Grid</title>
          <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/>
          <link rel="stylesheet" href="css/main.css">
            <link rel="stylesheet" href="css/bootstrap.css">
      </head>
      <body>
            <header class="container_flex top-banner">
              <div class="row">
                   <div class="col-md-6">
                       <img class="logo" src="images/att2.png" alt="logo">
                   </div>
                   <div class="col-md-6" >
                        <h1 class="header_main_title">Cynthia Hill</h1>
                        <h4 class="header_sub_title">Front-end …
0
Hi I'm building a html table from some imported JSON data

How do I fix the header row and scroll the data body similar to freeze panes  in excel

This is a mockup of what I'm trying to do The MOCK_DATA.json may not be enough to triger the overlow hence setting it 100px

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Ajax Table</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    	
<script type='text/javascript'>
	$(function() {
      // jQuery
       $('button').on('click', function (){
                    var link = "MOCK_DATA.json";
               $.ajax({
                url: link,
                   dataType: "json",
                   type: "GET",
//                   contentType: "application/json; charset=utf-8",
                   success: function (data) {
                   
                       console.dir(data);
                     var table = $('<table></table>').addClass('MyClass');
                  var RowCount=0;
                  var row;

                  $.each(data, function(i, val) {
                  row =$('<tr></tr>');
                   // console.log(i);  //this gives the object index/key
                   // console.log(val);  //this gives the object
                    $.each(val, function(i2, val2) {
                       if(RowCount===0){
                         var thead =$('<thead></thead>');
                          var th = $('<th></th>').text(i2);

Open in new window

0
We had a migration on our sharepoint farm from SP2010 to SP2016 and several things in our custom list forms really appear off and was looking to see if someone else had experienced this and might have a solution for correction. We do have the opportunity to re-migrate so we can make changes on the SP2010 side to prepare for final migration which will happen at the end of next week.

Issue 1 any person or group field on our new or edit forms show up weird, the two icons for check names and browse people directors are now outlines in obnoxious blue lines

Issue 2 the check names function appears to work but the browse triggers an error to the screen JSON is unidentified and rather than getting the old pop-up window it builds an addition to the bottom of the screen for a people selection which is very ugly. And it does not appear that new addition to the bottom of the screen works it just spins.

Issue 3 One of our very standard forms shows up as completely unusable screen shot attached enter image description here

Issue 4 When we include a people or group field on a display form we get a weird icon in front of the actual value see attached enter image description here

Issue 5 We also get a lot of these very strange pics pop up wherever we try to put the textname of a user or group on a page see attached enter image description here

THese are all show stoppers for us to migrate so we are scrambling to try and find answers to fix on the receiving end or on the …
0
Hello...

I'm having trouble getting JSON data to load into an HTML table. Can someone please pinpoint what I'm doing wrong. I am a web design newbie...trying to learn a new skillset. So any assistance is greatly appreciated!

Here is my JSON data:
 [
       {
           "firstName": "Clark",
           "lastName": "Kent",
           "job": "Reporter",
           "roll": 20
       },
       {
           "firstName": "Bruce",
           "lastName": "Wayne",
           "job": "CEO, Wayne Tech",
           "roll": 30
       },
       {
           "firstName": "Peter",
           "lastName": "Parker",
           "job": "Photographer",
           "roll": 40
       }
   ]


[b][u]Here Is a fetchResults js file:
[/u][/b]
var xhr = new XMLHttpRequest();

xhr.open("get", './sample.json', true);
xhr.onload = function(){
    var data  = JSON.parse(xhr.response);
    var host = document.getElementById("result");
    for(var i =0; i < data.length; i++){
        host.innerHTML = host.innerHTML + JSON.stringify(data[i]);
    }
}
xhr.send();

Open in new window


And here is the HTML where I am trying to create the table:

  <div class="col-12 center">
                    <table class="tblRestmnt">

                      <th>First Name</th>
                      <th>Last Name</th>
                      <th>Job</th>
                      <th>Roll</th>
                      <tr></tr>



                      <script>
                      $(document).ready(function(){
                        $.getJSON("sample.json", function(data){
                          var data = '';
                          $.each(data,function(key, value){
                            data += '<tr>';
                            data += '<td>'+value.firstName+'</td>';
                            data += '<td>'+value.lastName+'</td>';
                            data += '<td>'+value.job+'</td>';
                            data += '<td>'+value.roll+'</td>';
                            data += '</tr>';
                          }),
                          $('#data').append(data);

                        });
                      });
                      </script>

                    </table>
                      <div id="result"></div>
                  </div>

Open in new window

0
I have a custom list application which has a bunch of People/Group fields that worked great in SP2010 on the form the field space showed with two icons (lookup and check).

Code looks like this
<SharePoint:FormField runat="server" id="ff42{$Pos}" controlmode="Edit" fieldname="CSE" __designer:bind="{ddwrt:DataBind('u',concat('ff42',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@CSE')}" />

After converting to SP2016 the icons are outlined in blue amd when you click them you get a JSON error "JSON is Undefined.
0
Python: Series & Data Frames With Pandas
Python: Series & Data Frames With Pandas

Learn the basics of Python’s pandas library of series & data frames and how we can use these tools for data manipulation.

I'm getting a JSON object sent to a URL and need to read the contents and turn it into a string I can use to submit to a DB. I need a good tutorial that focuses on this specifically, or some guidance.
0
I have a URL set up that will receive the following JSON object:

[
  {
    "user":"12345678-4321-1234-4321-123456789123",
    "entity_type":"user",
    "datetime":"2012-04-07T22:26:10.947Z"
  }
]

Open in new window


I need something that can receive this data, put each of the three above into a separate string, then "do something" with each string. How do I do this?
0
I have set up a basic shopping cart which loops through the item id's in the cart and retrieves product details from the database from the id's. I am putting the data into an array and json encoding it. Their shopping cart contents are then displayed to them via jQuery.

I want to also show them the subtotal but I cannot put that into the loop. When putting it outside of the loop I don't know how to json encode it.

I tried this:

echo json_encode(array($cart_details, $response));

Open in new window


But even if that is correct, I don't know how to extract the arrays in jQuery.

$itemsInCart = "";
$response = array();

if(!isset($_SESSION['cart_array'])) {
	
	$itemsInCart = 0;

} else {

		$featured = "Yes";
		$cartTotal = "";
		foreach($_SESSION['cart_array'] as $each_item) {
			$item_id = $each_item['item_id'];
			
			$stmt = $link->prepare("SELECT `product_name`, `price`, `pic_name` FROM `products` as `p` INNER JOIN `product_images` as `pi` ON p.`id` = pi.`product_id` WHERE p.`id` = ? AND `featured` = ?");
			$stmt->bind_param("is", $item_id, $featured);
			$stmt->execute();
			$result = $stmt->get_result();
			$numRows = $result->num_rows;
			if($numRows > 0) {
				while($row = $result->fetch_assoc()) {
					$product_name = sanitize($row['product_name']);
					$price = sanitize(money_format('%.2n', $row['price']));
					$subtotal = money_format('%.2n', $each_item['quantity'] * $price);
					$pic_name = $row['pic_name'];
					$cartTotal = $subtotal + 

Open in new window

0
I have over 100000 mins with 2000 mp3 file that I would like to convert to text. Twilio has two vendors to do that but it is too expensive.
anyone know I can basically drop the files and run bulk so i can get my text from each mp 3?
0
i have asp.net app and a list of mp3 file in my c: drive. How can use <audio> to open them?
another question is I want to list all of the mp3 in table. For each row, I want to have media play (https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_source_src) , how can I do that?
0
I have a single field in a log table that contains this data:

Is it JSON?

How do I extract just the email address following the "to" field?

I have a text file version and could use some other scripting tool, even Excel, if it could work.

Thanks.

{"event": "failed", "severity": "temporary", "tags": [], "mailing-list": {"list-id": "satb_mailing2_nonspam.m.satb.com", "address": "satb_mailing2@m.satb.com", "sid": "1288499"}, "timestamp": 1446076551.295771, "envelope": {"targets": "sb@reply.sb.com", "transport": "smtp", "sender": "postmaster@m.satb.com"}, "delivery-status": {"code": null, "message": null, "retry-seconds": 900, "description": "MX lookup failed", "session-seconds": 0.0}, "kafka": {"topic": "iad_pipeline_events", "msg_size": 1761, "partition": 1, "key": "NTVmMWU0OTg3OGZhMTY0ZmQzYWUxMDg5", "consumer_group": "logstash-customer"}, "campaigns": [{"id": "g7d2t", "name": "BapChOwn"}], "log-level": "warn", "reason": "generic", "user-variables": {}, "flags": {"is-routed": null, "is-authenticated": true, "is-system-test": false, "is-test-mode": false}, "recipient-domain": "reply.sb.com", "message": {"headers": {"to": "scottbrown@reply.scottbrown.com", "message-id": "20151028223554.10459.56766@m.satb.com", "from": "Roberta <rob@satb.com>", "subject": “CWC!”}, "attachments": [{"filename": "Golden__MP3s_and_PDFs.zip", "content-type": "application/zip", "size": 26089706}], "recipients": ["sb@reply.sb.com"], "size": 26125372}, "recipient": “sb@reply.sb.com", "id": …
0

JSON

528

Solutions

568

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