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

x

JSON

529

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
How to Use the Help Bell
LVL 10
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.

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 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 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
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
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
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
Hi members,

Hoping to get some counseil I'm writing here my issue:

I have a php script that uses url_get_contents to execute a script and retrieve a json from another domain. Both ends are under my control.

The calling to the function is:

$this->url_to_call = 'http://example.com/b_controller.php';
$jsonData = array(
            'table' => 'countries',
            'key' => '44',
        );
$jsonDataEncoded = json_encode($jsonData);
$post = file_get_contents( $this->url_to_call, null, stream_context_create(array(
                    'http' => array(
                        'protocol_version' => 1.1,
                        'user_agent'       => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36',
                        'method'           => 'POST',
                        'header'           => "Content-type: application/json\r\n".
                            "Connection: close\r\n" .
                            "Content-length: " . strlen($jsonDataEncoded) . "\r\n",
                        'content'          => $jsonDataEncoded,
                    ),
                )));
$data = json_decode($post, true);

Open in new window


If I run this code, in the first attemp I get:

Warning: file_get_contents(http://example.com/b_controller.php): failed to open stream: An error occurred during the connection attempt because the connected part did not respond properly after a period of time, or there was an error in the established connection because the connected host could not respond. in C:\xampp\htdocs\origin_com\a_controller.php on line 220

But if I refresh the page or add if( !$data ) $data = $post = file_get_contents( $this->url_to_cal......; it reponses with the right json.

If I leave the script 2 minutes and re-run it again I get the error.

I have no clues why this is happening.

Any advice will be appreciated.
0
I have a database query that I want to export or convert to a json file.

The query result is something like this

path                         | name          
parameter.name.menu.myname | mike miller

Open in new window


Finaly I need a json structure like

"parameter": {
        "name": {
              "menu": {
                    "myname": " mike miller"
              }
         }
 }

Open in new window


How this is possible?
I work with mysql 10.1.x and php
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.

UseCase 1 :-  Http Method : Get , expected json is {"id":1, "effecitveDate" :"2017-08-13 08:10"} - working fine

UseCase 2 :- Http Method : Get, expecting a list of objects i.e. ["id":1, "effecitveDate" :"2017-08-13 08:10"} ,"id":2, "effecitveDate" :"2017-08-16 08:10"}

but I am getting  date like ["id":1, "effectiveDate": [
            2017,
            8,
            13,
            8,
            10
        ]},
"id":2, "effectiveDate": [
            2017,
            8,
            16,
            8,
            10]}
]

How to solve this date issue.
Note : I am using java8 LocalDateTime.
0
I use twilio api and download the recording below


/2010-04-01/Accounts/ACf071d40db95b8e4d9c206d62b626e6b3/Recordings/REf87ead782e21c8c5fb353992bce20a6dasdfasdfdas.json

How can i make it so I can listen it?
0
Hi Guys,

We wrote an application that downloads json files down to about 80/90 client machines, we have reworked the mechanism but cant get it work correctly

I want to know how we could enable our server to send http status code responses then I can use the reponse.statusCode to see if a new file is available and make this whole thing a lot easier and more robust.
0
I have a web part page displaying 5 web parts. Four of the web parts (Efforts, Phases, Capture Points & Areas) are "provider" web parts, and come from lists that are the sources of 4 lookup columns in the 5th "consumer" web part (Lessons Learned).

The provider web parts are displaying the Title column from the lists.

The Using Javascript/jQuery, I "connected" the 4 provider web parts to the consumer web part, such that when you click on a Title column value, the consumer web part is filtered to show only those records that have the clicked value in the relevant metadata column.

All that is working very nicely.

Now, my requirement is to go one step further, and display the number of items that will be displayed if you click on a Title column value in any of the 4 web parts. If there are none, a "0" should be displayed.

I've constructed a lists service query that successfully returns the number of items that exist for a given, hard-coded, metadata value:
[SiteURL]/_vti_bin/listdata.svc/[ListName]/$count?&$filter=Effort/Title eq 'AAA'

So, the goal is to display such an item count beside the corresponding provider web part value, such as:
Efforts web part:
AAA (10) //assuming there are 10 items in the consumer web part tagged with Effort 'AAA'

Now, I'm bumping up against the current limit of my abilities.

I know that I need code (javascript, rest, ajax, json) for each provider web part with looping to cycle through all of the TD cells that have …
0
<cfoutput>
<cftry>
	<cfhttp url="https://rest.bandsintown.com/artists/spencerkane/events?app_id=day6mgmt&start_date=2017-01-01" result="httpResult" charset="utf-8" method="get"/>
 	<cfset BITdata = deserializeJSON(httpResult.filecontent)/>
	<cfloop array="#BITdata#" index="post">
		<cfif StructKeyExists(post, "datetime")>
			<cfset event_date = post.datetime>
		<cfelse>
			<cfset event_date = "">
		</cfif>
		<cfif StructKeyExists(post, "venue.name")>
		    <cfset ev_title = post.venue.name>
		<cfelse>
            <cfset ev_title = "">
		</cfif>
		<cfif StructKeyExists(post, "venue.city")>
			<cfset city = post.venue.city>
		<cfelse>
			<cfset city = "">
		</cfif>
		<cfif StructKeyExists(post, "venue.region")>
			<cfset region = post.venue.region>
		<cfelse>
			<cfset region = "">
		</cfif>
		<cfif StructKeyExists(post, "offers.url")>
		<cfset tickets = post.offers.url>
			<cfelse>
		<cfset tickets = "">
			</cfif>

<!--- FEED OUTPUT --->        
<cfif not event_date is "">		
#event_date#<p>
#ev_title#<p>
#city#<p>
#region#<p>
#tickets#
<hr />
</cfif>		
	</cfloop>

	<cfcatch type="any">
		<p>
			<cfdump var="#cfcatch#" />
			#LSDateFormat(Now(), "dd-mm-yyyy")# #lsTimeFormat(Now(), "HH:mm")#<br />
			<a href="##">
				Oh, sorry... I can't connect to Bandsintown
			</a>
		</p>
	</cfcatch>

</cftry>
</cfoutput>

Open in new window


My output only gives me the datetime and none of the other structure data even though the raw feed in a browser window definitely shows there is more data to be displayed. I am using Adobe's output structure of data.struct1.substruct but it doesn't display anything.
0
Oh men,
Im wondering if you guys can give me some advice and examples of how i can position my web page in the proper manner,
some tricks or best practices for positioning my page locally
regards
0
Hi guys,

I seem to be having an issue with my site, where iradio.ie/listen will be hammered after a while, however if i turn on my cloudfare to "I'm under attack" it will work fine but will display a message which in turn deters visitors, i think it is to do with my player here http://iradio.ie/newPlayer but maybe the fact that the iradio app is also pointing to http://iradio.ie/listen to get the audio streams, it is not able to handle the traffic or maybe its just down to poor config?

Any help would be greatly appreciated
0
hi
i have a method that should display the fist 2 results and when i press the more results button it should display the list with the added results. i log the data in initial step, and it is ok, then after the press it is ok. but when i want to loop the results and display them i get [object Object]. when i try the async pipe i get:
InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe'

if i try the json pipe i get:
Converting circular structure to JSON
    at Object.stringify (<anonymous>)

i attach the image that show that the console results are ok.

this is the method:
  limit:BehaviorSubject<number> = new BehaviorSubject<number>(2);
  lastKey:string = '';
  queryable:boolean = true;

  paginationResults(){

    this.getLastKey();

    let list =  this.db.list('playlists', {
      query: {
        orderByKey: true,
        limitToFirst: this.limit,
      }
    });

    
  return list.subscribe(
      (data) => {
        console.log('returned data: ',  data);
        if(data.length > 0){
          //if the lastkey === to the last key in the database = stop query
          if(data[data.length - 1].$key === this.lastKey){
            this.queryable = false;
          }else{
            this.queryable = true;
          }
        }
      }
    );

  }

  getLastKey(){
    this.db.list('playlists',{
      query: {
        orderByKey: true,
        limitToLast: 1 //that get us the last key of the list
      }
    }).subscribe(
      (data) => {
        

Open in new window

0
Hi,

I'm looking to use the GoogleFinance module
https://github.com/hongtaocai/googlefinance

to record the stock price every few minutes into a MySQL database

From the documentation I can see that it will require a list of stocks  - that I will keep in csv file

I'm having difficulty parsing the JSON that comes back in order read it into a variable.
'TypeError: list indices must be integers, not str'

Can anyone direct me to some resources that might give me a steer on how best to achieve this?

I will look to create a table for each stock being tracked
0
Moving data to the cloud? Find out if you’re ready
LVL 3
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Hello,
  I am using swagger - YAML and I need some help on how to define  a json response object


Here is the JSON:

{
    "keywords": [],
    "distance": "25",
    "jobType": "all",
    "sectorId": "0",
    "location": {
        "lat": "33.7489954",
        "lng": "-84.3879824",
        "name": "Atlanta, GA"
    }
}

please note the keywords can be an empty array [] or have value like ['a','b','c']

Thanks for your help
0
Hello nodejs experts

Is there is anything more on node js standards?  


All urls must be in lower case

Ex: /notification/sendotp

Use HTTP verbs (GET, POST, PUT, DELETE) to operate on the collections and elements.

Use GET – for retrieving single or list data

Use POST – for create data

Use PUT – for update data

Use DELETE – for delete data

HTTP METHOD

POST

GET

PUT

DELETE

CRUD OP

CREATE

READ

UPDATE

DELETE


URLs should include nouns, not verbs in API names. Avoid get,update,save, delete, list in API names.

Maintain singular and plural nouns for APIs.

Ex: for single image retrive – GET - /user/image

For list of images – GET – user/images

User Token must be in headers only. Not as path param or in json body

Use resource, sub-resources for relations

Ex: for user videos use - /user/videos

Put the version number at the base of your URL. /v1/user/images

Controller will have only mandatory parameter validations and sending success, error responses no business logic. Use Service and Helper files for business logic. DAO for db calls

Handle Errors with HTTP status codes

200 – OK – Everything is fine. Created, Saved, Data found

400 – Validations Failed, Missing Mandatory Params, No data found, User already exists, already voted, in valid comment, comment not allowed within a hour, invalid user, invalid video, Video not found

500 – Unknown error, Database error, ES down, timeout from third-party. …
0
http://maps.aerophotos.cf/test.
Basically make the markers update every second or so from the JSON file aswell as display the data in the JSON file i.e altitude callsign etc when clicking on marker.
0
I am trying to get a json to vb.net class.
I have used the Visual studio converter for this and generated the class, but it is not working.
 The commented   ' Public Property Wlisting() As WooData does not work,
I have tried different methods of calling an array or a list but always get the same error.  The Json that come over appears correctly formed, it is the inability to get it into a class which is the problem.

The line :

  Dim WooResponse = JsonConvert.DeserializeObject(Of WooCommerceData.Results)(result)

gives the following error:
Newtonsoft.Json.JsonSerializationException: 'Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Zetsy.WooCommerceData.Results' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.

To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.

Zit appears I should be calling this as a differnt type of list, but what I have tried gives the same error
=========================================================================


The class is the following:

Namespace WooCommerceData
    Public Class Results
        Public Property Wlistings As List(Of WooData)
        ' Public …
0
How to populate select options from database in jquery. I am using datatables editor plugin to edit the row.

var local_path = "/dashboardlocal_list/0/?format=json";
var local_editor = new $.fn.dataTable.Editor( {
        idSrc:  'id',
        ajax: {
            // create: {
            //     type: 'POST',
            //     url:  '/dashboard/local_detail/'+ idSrc +'/?format=api'
            // },
            edit: {
                type: 'PUT',
                url:  '/dashboard/local_detail/_id_/',
                data: function (d) {
                        var updated_data = {};
                        $.each( d.data, function (id, value) {
                            updated_data['description'] = value['description'];
                            updated_data['start_date'] = value['start_date'];
                            updated_data['end_date'] = value['end_date'];
                            updated_data['task.name'] = value['task.name'];
                                                             } );
                        console.log(updated_data);
                        return updated_data;
                                 },

                success: function() {
                        console.log('Updated')
                        workorder_table.api().ajax.reload();
                                    },
                    },
            remove: {
                type: 'DELETE',
                url:  …
0
Hye experts, i have a problem to display data in data datagrid based on searching..can someone look it up..
Thank you for your help

Here is my code: test3.php

<?php
include "utama.php";
?>

<script type="text/javascript">
 function doSearch(){
    $('#tt').datagrid('load',{
        MUKIM: $('#mukim').val()
    });
}
</script>




<table id="tt" class="easyui-datagrid" style="width:600px;height:250px"
        url="test4.php" toolbar="#tb"
        title="Load Data" iconCls="icon-save"
        rownumbers="true" pagination="true">
    <thead>
        <tr>
            <th field="MUKIM" width="80">MUKIM</th>
            <th field="KAWASAN" width="80">KAWASAN</th>
            <th field="NAMA_KAWASAN" width="80" align="right">NAMA_KAWASAN</th>
        </tr>
    </thead>
</table>

<div id="tb" style="padding:3px">
    <div>
    <input name="MUKIM" id="mukim" class="easyui-combobox" style="width:100%"
            data-options= "label: 'MUKIM : ',
            valueField: 'MUKIM',
            textField: 'NAMA_MUKIM',
            url: 'dropdown_mukim.php'">
    </div>
    <a href="#" class="easyui-linkbutton" plain="true" onclick="doSearch()">Search</a>
</div>

code test4.php

<?php
include "connection.php";
$mukim = isset($_POST['mukim']);


if (isset( $_POST ["mukim"] ))
{
    $mukim = $_POST ["mukim"];
}

// echo  $name ;
// echo $phone;
// echo $mukim;

$rs = $conn->prepare("SELECT KAWASAN, NAMA_KAWASAN, MUKIM FROM …
0

JSON

529

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