JSONSponsored by Jamf Now

715

Solutions

718

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 writing a C# .Net function that reads a Json message sent as part of a HttpRequest. The HttpRequestMessage includes the Json message as in an encoded format and as a parameter as follows (for example):
url%3Dhttp%3A%2F%2Fwww.somewebsite.com%2Fsomepage%26page_name%3Dsomepagename%26%26data.json%3D%7B%22time_submitted%22%3A%5B%2209%3A51+PM+UTC%22%5D%2C%22emailaddress%22%3A%5B%22someoneemail%40yahoo.com%22%5D%2C%22device%22%3A%5B%22desktop%22%5D%2C%22page_uuid%22%3A%5B%22ac272d63-abcd-4d38-8ee6-5d36875ea098%22%5D%2C%22fc_referrer%22%3A%5B%22%28not+set%29%22%5D%7D

The problem I have is how to read and decode the Json data in my C# function (the function is running in Azure).

My code starts like this:

using System.Net;
using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)

{

    string jsonContent = await req.Content.ReadAsStringAsync(); //This works fine and reads the encoded Json message
   
     JObject o = JObject.Parse(jsonContent); // This comes back with error: Newtonsoft.Json: Unexpected character encountered while parsing value: p. Path '', line 0, position 0.


If I test using a decoded httpsrequestmessage, everything works fine. However, with the encoded Json value, I can't read the data. The encoded Json data is sent from another system so I have no control to …
0
Free Tool: IP Lookup
LVL 12
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.

I am integrating into a webservice, it returns json, here are 2 types of results from it
{"numFound":1,"QTime":77,"attributions":"http://www.gisgraphy.com/attributions.html","result":[{"id":100004730,"lng":36.710459425750635,"lat":-1.336961662155654,"streetName":"Marula Lane","city":"Bulbul","state":"Kajiado","countryCode":"KE","geocodingLevel":"STREET","distance":300.4280656229352,"adm1Name":"Kajiado","formatedFull":"Marula Lane, Bulbul, Kajiado, Kenya","formatedPostal":"Marula Lane, Bulbul","speedMode":"OSM","maxSpeed":"30 mph","azimuthStart":267,"azimuthEnd":251,"length":1161.411457366,"sourceId":33136013}]}



{"numFound":1,"QTime":2537,"attributions":"http://www.gisgraphy.com/attributions.html","result":[{"id":22523950,"lng":36.81669998168945,"lat":-1.2833000421524048,"zipCode":"09831","city":"APO AE","countryCode":"US","geocodingLevel":"CITY","distance":13413.984061400277,"formatedFull":"APO AE,  (09831), United States","formatedPostal":"APO AE, 09831"}]}

Open in new window


I've used the visual studio paste special as JSON class on the first result as that seems to have more info
I'm using the 2nd result as the  test scenario

I then use this code
Result json1 = JsonConvert.DeserializeObject<Result>(jResult);

Open in new window


But all the objects are empty or null

What am I doing wrong?
0
How to Add MIME type like .json  type in iis by installer.
0
Hi, I am writing ASP.NET Web API to run on Windows/Azure.
What .Net Framework would you prefer 4.* or Core?

Thanks.
0
JSON Formatting Tool

What is the best tool (that's quick & easy) to take JSON in a "paragraph/horizontal" format,
and format it into the "common way" vertically so it's easier to read?

Even better, if you can do the same thing, but convert to YAML (vertically).

It can be a standalone tool if need be...or some kind of plugin. FYI...I typically use Visual Studio 'Code' for my
text editor in general, so if that helps with any ideas. However, I'm open to use other suggestions, at least for this purpose.

When I decode AWS encode errors messages, it comes out all smashed together in a horizontal format, almost as
cryptic as the encoded message itself and it's hard to read.
0
Hi All

I am working on C# Desktop App.  My below code is working fine for retrieving JSON data from api when I am using http url.
 using (var w = new WebClient())
            {
                 var json_data = string.Empty;
                // attempt to download JSON data as a string
                try
                {
                  json_data = w.DownloadString(url);
                }
               Catch(Exception ex)
              {
              }
          }

But when the url started using https, then my above code started giving me following exception.

[System.Net.WebException] = {"The underlying connection was closed: An unexpected error occurred on a send."}

Can anyone Kindly help me sort out this exception.

Thanks in adance.
0
Hello,
My problem is that the "JsonUtility.FromJson" is not working on Android, only works on the Unity Editor.
This is my code:
IEnumerator LoadStreamingAsset(string fileName)
    {
        string result;
        string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, fileName);

        if (filePath.Contains("://") || filePath.Contains(":///"))
        {
            WWW www = new WWW(filePath);
            yield return www;
            result = www.text;
        }
        else
        {
            result = File.ReadAllText(filePath);
        }
        GameData loadedData = JsonUtility.FromJson<GameData >(result);
        Questions = loadedData.Questions ;
        Debug.Log("Loaded file: " + result);
    }

Open in new window


Any help?
0
I have an array of checkboxes coming from a collection.

See below:

<div class="form-group">
    Select days in a week :
    <td class="even" *ngFor="let item of dayList">
    <input value="{{item.check}}" type="checkbox" checked="item.check" formControlName = "selectedDays">  {{item}}
   </div>

Open in new window


formControlName I am set as selectedDays.

I need to generate JSON object for the selected checkbox values.

Currently, i am getting boolean value in selectedDays. But I am supposed to get an array of checked values in an array inside JSON object.

this.dayList = ['Sun', 'Mon', 'Tue','Wed',"Thu","Fri","Sat"];

JSON Object looks like below, please note the value of selectedDays, it is supposed to be "Sun, Mon" based on selection, but it is showing as true.


 
Object
    date
    :
    "2"
    day
    :
    "Mon"
    hour
    :
    "3"
    minute
    :
    "3"
    schedulerjobtype
    :
    "Daily"
    selectedDays
    :
    true
    useCase
    :
    "UC 2"
    zone
    :
    "Zone 3"

Open in new window


How can I implement this?
0
I'm trying to get this json data

https://www.cryptocompare.com/api/data/coinlist/

Here's my code

import axios from 'axios';

axios.get("https://www.cryptocompare.com/api/data/coinlist/")
.then((result) => {
  console.log(result);
}).catch((err) => {
  console.log(err);
});

Open in new window


But I'm getting an error



How this error can be fixed to actually get the data?
0
i am trying to run

npm install mysql

command in cmd its giving me these error

npm ERR! Unexpected end of JSON input while parsing near '....tgz"},"engines":{"no'

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Users\HP\AppData\Roaming\npm-cache\_logs\2018-05-30T06_49_09_337Z-debug.log
0
Free Tool: Port Scanner
LVL 12
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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 have this json coming from an REST api. I now want to make a representaion of it in my asp.net site (I use vb.net for the moment). But I don't fully get it to work when I create the classes representing the json and deserialize it. This is how the json looks like when I copy it form Postman:
{
    "data": {
        "type": "vehicle",
        "attributes": {
            "regno": "HCA015",
            "vin": "WF0MXXGBWMDP17671"
        },
        "links": [
            {
                "rel": "self",
                "uri": "vehicle/vin/WF0MXXGBWMDP17671"
            },
            {
                "rel": "biluppgifter",
                "uri": "https://biluppgifter.se/fordon/HCA015"
            }
        ],
        "basic": {
            "data": {
                "make": "Ford",
                "model": "GALAXY 2.0 TDCi",
                "status": 2,
                "color": "Svart",
                "type": "PB",
                "vehicle_year": 2013,
                "model_year": 2013
            }
        },
        "inspection": {
            "data": {
                "latest_inspection": "2016-09-19T00:00:00+02:00",
                "inspection_valid_until": "2018-09-30T00:00:00+02:00",
                "meter": 38650,
                "next_inspection_range": [
                    "2018-05-01T00:00:00+02:00",
                    "2018-09-30T00:00:00+02:00"
                ]
            }
        },
        "status": {
            "data": {
                

Open in new window

0
Oracle PLSQL: How to parse JSON response(without using any 3rd party library packages) using PLSQL code. Database is Oracle 11g.
JSON response is {"blocked":true,"description":"Blocked due to uncompleted Blue evaluations or manually blocked.","userid":"9600946LS"}
Using plsql,How to parse and read the values from the above JSON response.

My Sample program:
-------------------------------
CREATE OR REPLACE package try_json is
  procedure getData ;
end try_json;
/

CREATE OR REPLACE package body try_json IS
--RITM0011461
procedure getData is

request utl_http.req;
response utl_http.resp;
n NUMBER;
url varchar2(4000) := 'http://localhost:9002/cinema';
name varchar2(4000);
buffer varchar2(4000);
--json_value1 VARCHAR2(10);
--in_data json;
clob_buff CLOB;
--content varchar2(4000) := '{"code":100,"id": "APA91bFSmD_gBsUwO_hraRZL20mt8p4ejGn5fC7tlciINT50Ad8oIod2T-64GVk_8rProqXGEpYuDcoQogG0L7a0TuyeeisTcmHiUUONbnZzn4_u0ED7QD_iNeVkh1ZgU8Pa-HRtfgJUgOT-TyvlM9hB4Yn9fvOPud","data": "alert alert"}';

begin

    UTL_HTTP.SET_RESPONSE_ERROR_CHECK(FALSE);
    utl_http.set_wallet('file:/u01/app/oracle/product/wallet/esb_trust', 'Oracle01');
    request := UTL_HTTP.BEGIN_REQUEST(url, 'GET');
    UTL_HTTP.SET_HEADER(request, 'User-Agent', 'Mozilla/4.0');
    response := UTL_HTTP.GET_RESPONSE(request);
    DBMS_OUTPUT.PUT_LINE('HTTP response status code: ' || response.status_code);

    IF response.status_code = 200 THEN
        begin
          loop
          …
0
i want to make inside json Array list inside array list

{
      "groupInformationKey": 6,
      "groupName": "PortalAdministrator",
      "subGroups": [{
      "groupInformationKey": 52,
      "groupName": "axfxf",
      "subGroups": [{
      "groupInformationKey": 53,
      "groupName": "axx",
      "subGroups": [{groupInformationKey": 54,
      "groupName": "ox",
      "subGroups": null,
      "subNestedGroup": null,
      }

how to make with array list and pojo with sub group inside subgroup and so on
0
I'm trying to use Rest assured and JsonPath to extract a value from the pzSetRuleSetFilter field where the pyRuleSetName equals a certain value (TradeMarks in this case). I keep getting the error below. Any ideas on how I can fix this and extract the value would be great

invalid JSON expression:Script1.groovy: 1: expecting EOF, found '[' @ line 1, column 39.

My Query System.out.println(response.jsonPath().getString("$..pxResults[?(@.pyRuleSetName == 'TradeMarks')].pzSetRuleSetFilter"));

See attachment for a screenshot of some of the Json response from SoapUI
Capture.PNG
0
How to make api for this code in java using jersey.

post request username and i want user full name in return in json form.

package example;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Somthing {
     public static void main(String[] args) throws SQLException, ClassNotFoundException {
		Class.forName("");	
		Connection conn = DriverManager.getConnection("");
		System.out.println("Connected");
                PreparedStatement statement =  conn.prepareStatement("SELECT userfullname From this where username = 'raj'");
                ResultSet result = statement.executeQuery();
                
                while (result.next()) {
                 String s =  result.getString("usefull_name");
                    
                System.out.println(s);
                                                       
	}                                            
     }   
    
}

Open in new window

0
HelIo to the experts

I created a spring boot application which uses the "@RestController Annotation" to generate an "ArrayList" as JSON. This will look like this:

[{"id":2374273, "url": "https://google.com"}, {"id":2374274, "url": "https://google.com"}]

Open in new window


However, the output should be as follows:

{"urls": [{"id":2374273, "url": "https://google.com"}, {"id":2374274, "url": "https://google.com"}]}

Open in new window


That means the JSON array should have an array name (name = "urls") in the output.

How can I solve this?

Greetings,
Sven
0
how to make this type of api in java using jersey and get value from mssql server.

http://api.androiddeft.com/cities/cities_array.json
0
I'm using spring boot to load image from server but i can't se the pictire in the browser
0
Hi everyone this is my first question related to java. I am new in building api in java i am passing the null value in json i want some random value in json response which are come from database my code is working in java code is below on java.
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Types;
import com.pal.api.application.ApplicationAPI.DBConnection;
import Modal.AddContactRequest;

public class AddContact {
	public String addContact(AddContactRequest add) {
		Connection c= DBConnection.getConn();		
		//String cc = "";
		String result = "";
		try {
			 CallableStatement stmt= c.prepareCall("{call something( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?)}");
			 stmt.setString(1, add.getContactType());
			 stmt.setString(2, add.getCategory());
			 stmt.setString(3, add.getSubCategory());
			 stmt.setString(4, add.getTitle());
			 stmt.setString(5, add.getFirstName());
			 stmt.setString(6, add.getMiddleName());
			 stmt.setString(7, add.getLastName());
			 stmt.setString(8, add.getDesignation());
			 stmt.setString(9, add.getMobile());
			 stmt.setString(10, add.getPhoneNo());
			 stmt.setString(11, add.getDOB());
			 stmt.setString(12, add.getDOA());
			 stmt.setString(13, add.getEmail());
             stmt.setInt(14, add.getLocationID());
             stmt.setString(15, add.getActive());
             stmt.setString(16, add.getContactCode());
             stmt.setString(17, "");
             //ResultSet rs = 

Open in new window

0
Cloud Class® Course: Certified Penetration Testing
LVL 12
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

PowerApps problem:

I have a gallery that has items = Clients, a second gallery items = Projects where Client name = selected client gallery name.  That works just fine.

I also have an icon to add a new project for the selected client and it navigates to a new screen displaying a form for Projects, displaymode = new.  I also use JSON code to display the client name which is a lookup field in Projects pointing to clients.  the default on the datacard displays the correct Client title on the form.

However, when I submitform, I get a server error.  I have determined this error is that the client name lookup does not have a proper value.  In order to get the value correct, I have to click on the dropdown and choose a value from the list of client items.  I don't want this to be the case for users as the app should maintain the links automatically.

I have also created new lists and get the same result (just a title in Client, title and lookup in Projects).  I assume some attribute for the item or datacard is incorrect but can't find out which one.  I have been told this is just supposed to work, but not for me.  Please help
0
I am trying to us column formatting in SharePoint Online and am very new to JSON.  I am trying to use conditional formatting based on another column.  This was the code I was using when we could do calculated columns.

I would really appreciate anyones help getting me started on how to do this.

=IF(CAI=”Green”,”<img src=’../SiteAssets/Green.png’ border=’0'/><div style=’font-size: 75%;color: white; position:relative; text-align:center; width: 88px;top:-33px;word-wrap: break-word;’>”&[CAI Vendors]&”</div>”,IF(CAI=”Yellow”,”<img src=’../SiteAssets/Yellow.png’ border=’0'/><div style=’font-size: 75%;color: black; position:relative; text-align:center; width: 88px;top:-33px;word-wrap: break-word;’>”&[CAI Vendors]&”</div>”,IF(CAI=”Red”,”<img src=’..../SiteAssets/Red.png’ border=’0'/><div style=’font-size: 75%;color: white; position:relative; text-align:center; width: 88px;top:-33px;word-wrap: break-word;’>”&[CAI Vendors]&”</div>”,””)))
1
using laravel 5.6 only( latest version)Creating a webpage with a form that has the following text input fields: Product name, Quantity in stock, Price per item. The submitted data of the form should be saved in an XML / JSON file with valid XML / JSON syntax. Underneath of the form, the web page should display all of the data which has been submitted in rows ordered by date time submitted, the order of the data columns should be: Product name, Quantity in stock, Price per item, Datetime submitted, Total value number. The "Total value number" should be calculated as (Quantity in stock * Price per item). The last row should how a sum total of all of the Total Value numbers. Solution requirements: Use Php / Html / Javascript / Css. Use Twitter Bootstrap. The form should be submitting the data and updating the data being displayed on the page using Ajax. Thanks in advance.
0
We are using a LPR (License Plate Recognition) system developed by OpenALPR.com and it has an option to send license plate data to a webhook.

I wanted to know if anyone could think of a way to process the JSON data from the webhook and have it come out the other end looking like a POS (Point of Sale) device or even just in a format that would be able to be sent to a real POS device.

The goal is to use the webhook to send the JSON data which contains license plate, vehicle make, and color to my VMS (Avigilon) which accepts POS data so that video can be tagged with the information about the cars directly in the VMS software.
OpenALPR-webhooks.jpg
0
I am trying to implement a map/direction based application using Google maps V3 API. So far I have been able to display the map and show directions for two locations selected. the first one is my current location , the second one is the location of costumer (his/her information exist in my database). All the markers are being displayed in the output properly.

you'll see that in the form select box is automatically detect user's location, Also, i add a panel in which to display directions.

the Destination field show to us the code client (code client is the code of costumers , it's a number ) so when we select the code client from the destination field it take the Geoaddress of this costumer (the owner of this code client) and it desplay location to it in the map from our location.

PS0 :
sorry about my english language , i try to explain good for you even i don't speak good english language

PS1 : code client and Geosddress and longitude and latitude ... all information in my database

PS2 : the code client is the code of costumer

information about the code

First, i create new objects before the init function - DirectionsService and DirectionsRenderer. and i configure the directionsDisplay object. i did it inside init function. Also, i add autodetection of user's location to init function.

i use W3C Geolocation. If the geolocation succeds we use Geocoding to get the user's address. If this succeds we enter that location to the …
0
I have a rest api webservice which is going to return data in form of json doc. In my case it’s a object which I serialize via newtonsoft json. Works all fine but the json string I get in postman has all the escape slashes.  How can I get rid of those other then running a replace
0

JSONSponsored by Jamf Now

715

Solutions

718

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