[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

JSON

784

Solutions

785

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 want to write the code in vb6 (Visual Basic6) language to send sms through web api (after creating account in smsgateway.me site and mobile app in my android phone set) using json method (and how to get token) in vb6. Actuallay i know how to send sms using http url but unable to send sms through json). can you help in this case? thanks
0
HTML5 and CSS3 Fundamentals
LVL 12
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

I'm trying to learn about web APIs and was wondering if you could help me with a simple one to retrieve information about an online image.  An example URL could be
https://www.google.co.uk/imgres?imgurl=https%3A%2F%2Fvignette.wikia.nocookie.net%2Fjurassicpark%2Fimages%2F7%2F74%2FApatosaurus.png%2Frevision%2Flatest%3Fcb%3D20150103191434&imgrefurl=http%3A%2F%2Fjurassicpark.wikia.com%2Fwiki%2FApatosaurus&docid=inqHuw-Ju5m40M&tbnid=rDDyWwT3vIXnGM%3A&vet=10ahUKEwiD34KBu5LeAhUkJMAKHb9gADEQMwhqKAIwAg..i&w=1288&h=540&bih=969&biw=1920&q=apatosaurus&ved=0ahUKEwiD34KBu5LeAhUkJMAKHb9gADEQMwhqKAIwAg&iact=mrc&uact=8

How could I build a RESTful API which accepts the image url as a parameter and retrieve information about the image must be retrieved responding in JSON format.  Is it also possible to create a web client to call the API.  It only needs a single page to accept input for the url, a button to call the API, and an area to display the response.

I'm using C# within Visual Studio 2017 community edition.
0
Hello -

I need help formatting a sharepoint column with JSON.  I am using O365 which allows custom formatting of columns using JSON.  I need to keep the column format as a number format (cannot use text format) and need to basically replace the thousands comma with a hyphen.  So, a number like 18,212 would show up at 18-212.

Again, I can't change the column format to be text.  I have very limited experience with JSON, so any help would be appreciated.
0
I have a PowerShell script which generates JSON output of VM objects in a vSphere environment.   Each VM has a path property which represents the location of the VM in the folder structure.  Rather than the folders be represented in a property, how can I modify the script to use the path value to generate folder objects with the VM objects inside?

PowerShell Example:
$SQL = "USE $SQLDatabase SELECT top 2 * FROM VMs"
$computers = Invoke-sqlcmd -query $SQL -ServerInstance $SQLInstance -Username $SQLUsername -Password $SQLPassword

$connections = @()
$customProperties = @()

ForEach ($computer in $computers) {

    $connection = New-Object pscustomobject -Property @{
        "Type" = $computer.Type;
        "Name" = $computer.Name
        "ComputerName" = $computer.ComputerName
        "Path" = $computer.$path

    }
    $connections += $connection
}

@{
    Objects = $connections
} |
ConvertTo-Json -Depth 100 |
Write-Host]

Open in new window


Current Output Example:
{
  "Objects": [
    {
      "Path": "Clients A-K/Client 1 (ACC)",
      "ComputerName": "VM1",
      "Name": "VM1",
      "Type": "TerminalConnection"
    },
    {
      "Path": "Clients A-K/Client 1(ACC)",
      "ComputerName": "VM2",
      "Name": "VM2",
      "Type": "RemoteDesktopConnection"
    }
  ]
}

Open in new window



Goal Output Example:
{
  "Objects": [
    {
      "Type": "Folder",
      "Name": "Clients A-K",
      "Objects": [
        {
          "Type": "Folder",
          "Name": "Client 1 (ACC)",
          "Objects": [
            {
              "Type": "TerminalConnection",
              "Name": "VM1",
              "ComputerName": "VM1",
            },
            {
              "Type": "RemoteDesktopConnection",
              "Name": "VM2",
              "ComputerName": "VM2",
            }
          ]
        }
      ]
    }
  ]
}

Open in new window

0
How to build table using javascript for below JSON , I want to display Total for each location and RecordType first and then detail for location and recordtype and add extra blank row for each different category


{
   "action":"query",
   "Warehouse":"NJ",
   "records":[
      {
         "Location":"UK",
         "RecordType":"Fruits",
         "Qty":16,
         "Name":"Total"
      },
      {
         "Location":"UK",
         "RecordType":"Grocery",
         "Qty":11,
         "Name":"Total"
      },
      {
         "Location":"US",
         "RecordType":"Fruits",
         "Qty":5,
         "Name":"Total"
      },
        {
         "Location":"US",
         "RecordType":"Grocery",
         "Qty":17,
         "Name":"Total"
      },
      {
         "Location":"US",
         "RecordType":"Fruits",
         "Productid":123,
         "Qty":5,
         "Name":"Apple"
      },
      {
         "Location":"UK",
         "RecordType":"Fruits",
         "Productid":124,
         "Qty":11,
         "Name":"Bananna"
      },

      {
         "Location":"US",
         "RecordType":"Grocery",
         "Productid":223,
         "Qty":6,
         "Name":"Rice"
      },
      {
         "Location":"UK",
         "RecordType":"Grocery",
         "Productid":224,
         "Qty":11,
         "Name":"Beans"
      }
   ]
}

table
Location  Name   RecordType    ProductID, Qty
US        ,Total   ,Grocery    ,          ,6
US       …
0
Hi Experts,
Need some urgent help on quering json object please


1. How to query attached json file and return true or false based on string contains logic check.
2. Parse each stdout element in the json file.
3. Loop through each stdout and check for if it contains "HELLOWORLD_APPLICATION_DEPLOYMENT_SUCCESSFUL"

below filter will return all stdout element. but not able to figure out how to include contains logic and get true/false
jpath = plays[*].tasks[*].hosts.localhost.stdout


Have attacehd few screenshot on how i'm trying this online json editor

https://jsoneditoronline.org/
json_editor1.jpg
json_editor2_with_filter.jpg
success.json
0
Hello there.

I am trying to make server pagination work for:
http://bootstrap-table.wenzhixin.net.cn/documentation/

My backend is Python Flask and I have this function preparing the data.
It works but I cannot understand how to paginate it...
The parameters that I receive from fronteng get call are the ones you see:
@app.route('/json/items')
def get_items():
    """
    Return a JSON containing all items
    """
    order = request.args.get('order')
    offset = request.args.get('offset')
    limit = request.args.get('limit')
    items = db.session.query(Item).all()
    return jsonify([i.serialize for i in items])

Thanks for you help and patience.
0
Hi,

is there's a way to consume JSON API in SSRS?  I did some research and I landed to a 3rd party ODBC driver for ZappySys, is there's a free way, as my company won't be paying for a license.

thanks
0
I have two collection
Name and address which i exported as json from relation database

I want to merge that two collection as below how can i do that.


Thanks

I
{
    "_id" : ObjectId("5bba4cadb20b7e2f3c1436fd"),
    "o_id" : 5,
    "surname" : "sam",
    "firstname" : "sam",
    "created_date" : "2018-10-07",
    "address" : {
        "address1" : "177 road",
        "city" : "MI"
    }
}
0
I need the second to last item in the json response at the end of the code to include all the skus in each of the orders (so users can order all of that order's item's again all at once). What I have in there now only returns the sku in the last order. A preview of the current json response is embedded directly below. json
                // Organized Order Products into shipments //
                $shipments = array();
                foreach($order['order_details'] as $prod) {
            	   $grp = $dbAccessor->getShipmentGroup($prod['SKU']);
            	   if(!isset($shipments[$grp])) {
            	      $shipments[$grp] = array();  
            	   }

            	   $shipments[$grp][] = array('sku'             => $prod['SKU'],
                                              'name'            => $prod['Product'],
                                              'qty'             => $prod['qty'],
                                              'url'             => str_replace('http://www.mysite.com', '', $dbAccessor->getProductUrl($prod['SKU'])),
                                              'image_url'       => "/images/sku/small/".$dbAccessor->getSkuImage($prod['SKU']),
                                              'supplier_sku'    => $dbAccessor->getSupplierSku($prod['SKU']),
                                              'is_discontinued' => $dbAccessor->isDiscontinued($prod['SKU']),
                                              'supplier'       

Open in new window

0
Exploring SharePoint 2016
LVL 12
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

msg.topic = "Insert into mytable(DeviceId,Line,outPIN,count,Time) values (?,?,?,?,?)";
msg.payload = [{"DeviceId": 1,
"Line": 1,
"outPIN": "GPIO1",
"count": 15,
"Time": "2018-09-23 08:14:45"},
{"DeviceId": 1,
"Line": 1,
"outPIN": "GPIO1",
"count": 15,
"Time": "2018-09-23 08:15:13"},
{"DeviceId": 1,
"Line": 1,
"outPIN": "GPIO1",
"count": 15,
"Time": "2018-09-23 10:45:36"},
{"DeviceId": 1,
"Line": 1,
"outPIN": "GPIO1",
"count": 15,
"Time": "2018-09-23 10:48:51"}]
return msg;

Open in new window

Error message : msg : error

"Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?)' at line 1"
0
The following is coded in Laravel framework:

QUERY

$shipping = DB::table('shipping')->where('country',$delivery->country)->first();
$data= json_decode(json_encode($shipping),true);

Open in new window


RESULT

array (
  'id' => 3,
  'carrier' => 'EN',
  'country' => 'AU',
  'rates_json' => '{"rates": [{"international": [{"zone4": [{"to_kg": "2", "total": "1", "from_kg": "1"}, {"to_kg": "4", "total": "2", "from_kg": "3"}]}]}]}',
)  

Open in new window


In MySQL database i stored rates_json in a json datatype column. The attribute from_kg and to_kg is a range.  

I intend to retrieve the total if a value is between the range. For instance, if value 1.5 is between  1 and 2 then the total is 1.

Your help is appreciated.

Thank You.
0
I was sending XML in SOAP envelope to a web consuming server here at Lone Star. The Web consuming service has now switched from XML to JSON. Does the SOAP envelope change? If so in what way? I'm attaching the actual output to the Web Service. Using Krengeltech's RPG-XML to generate the XML data formatted and wrapping it in the SOAP envelope. Krengeltech also has a JSON api to perform the data mapping in JSON instead of XML. I need help creating the 'wrapped' soap statements
0
I have setup Code Pipeline to build a docker instance and deploy it on a ECS cluster, I have created my buildspec.yml and everything is working, however I need to adjust my buildspec.yml to print image definitions that setup a health check but so far its not working. Here is my current code for my buildspec.html

version: 0.2

phases:
  install:
    commands:
      - echo Entered the update phase...
      # Updates Docker Instance
      - apt-get update -y
  pre_build:
    commands:
      - echo Logging in to Amazon ECR...
      - aws --version
      - $(aws ecr get-login --region ap-southeast-2 --no-include-email)
      # ECS Repository URI
      - REPOSITORY_URI=###########.dkr.ecr.ap-southeast-2.amazonaws.com/###########
      - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
      - IMAGE_TAG=${COMMIT_HASH:=latest}
  build:
    commands:
      - echo Build started on `date`
      - echo Building the Docker image...          
      - docker build -t $REPOSITORY_URI:latest .
      - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
  post_build:
    commands:
      - echo Build completed on `date`
      - echo Pushing the Docker images...
      - docker push $REPOSITORY_URI:latest
      - docker push $REPOSITORY_URI:$IMAGE_TAG
      - echo Writing image definitions file...
      # Prints Task Definitions
      - printf '[{"name":"website","imageUri":"%s","healthCheck":{"retries":3,"command":["/bin/bash curl -f http://localhost/ || exit

Open in new window

0
json string have parent and child and child has sub child(grand child). Here wanted to remove grand child. child name and grand child name is same so if i remove based on the name it will remove child and grand child.But I wanted to remove only GrandChild property. I have converted json string to JObject here my code snippet: i know this is wrong it deletes both child and grand child because names are same. Please find attached my Json object structure and json string. I am using C#.net. Please let me know if you need any information.

JObject jObject = JObject.Parse(jsonString);
jObject.Descendants()
.OfType<jproperty>()
.Where(attr => attr.Name.Contains("NameofChild"))
.ToList()
.ForEach(attr => attr.Remove());
json-string.txt
jsonStructure.jpg
0
I'm getting this error:
Exception has occurred: UnicodeDecodeError
'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

Using this code:
json_obj = urllib.request.urlopen(url).read() 

response = urllib.request.urlopen(url).read()

json_obj = str(response, 'utf-8')

data = json.loads(json_obj)

Open in new window

0
I have json which contains emoji emotions. I am trying to save it in DB but it cannot be inserted. My Db is UTF8 and also my collation is utf8.
Need help
0
I am trying to create a method which can retrieve JSON objects.  I’m using the Jama API (https://dev.jamasoftware.com/rest)
To simplify it I am using RestSharp
I start by using the Jama swagger tool to test the interface.  This produces a Response Body.  I take this response body and in visual studio create a new class using the paste special ‘paste JSON as classes’ command.

This results in a new class:

public class Item
    {

        public class Rootobject
        {
            public Meta meta { get; set; }
            public Links links { get; set; }
            public Datum[] data { get; set; }

            public static explicit operator Rootobject(List<object> v)
            {
                throw new NotImplementedException();
            }
        }

        public class Meta
        {
            public string status { get; set; }
            public DateTime timestamp { get; set; }
            public Pageinfo pageInfo { get; set; }
        }

        public class Pageinfo
        {
            public int startIndex { get; set; }
            public int resultCount { get; set; }
            public int totalResults { get; set; }
        }

        public class Links
        {
            public DataFieldsLookup5 datafieldslookup5 { get; set; }
            public DataLockLockedby datalocklockedBy { get; set; }
            public DataFieldsLookup6 datafieldslookup6 { get; set; }
            public DataFieldsLookup3 datafieldslookup3 { get; set; }
        

Open in new window

0
how to bring common database to object structured JSON.
Hi. I have a database query that will result a list out of tokens for translation.

application.title = "Korpuskonfigurator"
application.dialogs.username = "Username"
application.dialogs.errors.missingfields = "Bitte alle Felder ausfüllen."
anschlagsart = "Anschlagsart"

And so forth. I have to bring this is an object structured JSON file for an external translation engine.
It have to look like s the following JSON sample. The token is splits by its points the structure have to be created.
I tried now a long time, but I complete fail. I hope anybody can give me a hint.

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

Open in new window

0
JavaScript Best Practices
LVL 12
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Hi there I have created webservice client which works fine when posting single parameterized string. Now I need to pass multiple strings in one post. Can some please help me to guide in right directions.

From below code snipet I need to repeat whuMailInDispatchOrderLines multiple times.
Dim PostRepairDataRequest As New ServiceReference1.whuMailInDispatchUpdateInfoType With {
           .dispatchId = dispatchId, _
           .shipper = shipper, .trackingNumber = trackingNumber, _
           .repairOrders = {New ServiceReference1.whuMailInDispatchOrderLines() With {.oldSerialNumber = oldSerialNumber, .serialNumber = OrderLinesSerialNumber,
            .comptiaCode = comptiaCode, .comptiaModifier = comptiaModifier}}

Open in new window

0
Hi Experts,

Pls check below scenario and help
This json has two responses from and health check api call.
One with status code 200. Another one with 404.
Trying to set a variable/flag to false...if any one of the response is NOT 200. Basically not all success.
What is the best way to identify success/failure from attached json msg. Status code?

My request is how to identify this by using json_ query syntax. Should we query for != 200? so we can set the failure_flag = true?

I tried below online json editor with below syntax. but couldnt get the contains or equal to syntax working....please help
https://jsoneditoronline.org/
http://jmespath.org/

Syntax to get status code
 api_health_result.results[].status

Pls check the attached json msg.


Will utilize in Ansible Task:
  - name: "Set_fact on api result"
    set_fact:
      api_health_result_return_code: '{{api_health_result|json_query("results[].status")}}'
json_msg.json
0
i have a json in xamarin android application defined as below:
{"Items0":[{"ItemNo":"467","ItemCode":"wah","ItemDesc":"desc1","ItemUnitOfMeasurement":"","ItemPrice":"0.0000","ItemPrice_Cur":"LL","ItemPrice_TE":"0.0000","FromRoutCode":"EIY","ToRouteCode":"EIY","QtyInStock":"0","QtyInStock_Sec":"0","Has_Color_Size":"No","Has_SubItems":"No","Floating_Coefficient":"0","Coef_Sec_Qty_vs_Primary_Qty":"0","Manage_SubItems_Is_Mandatory":"No","Manage_Location":"No","ItemBarcode":"9900000004675","SubItemkey":"0","SubItemDesc":"","ItemType":"Item","ItemColor":"","ItemSize":"","NumCS_Color":"0","NumCS_Size":"0","ItemShowKey":"wah","ItemSearchKey":"467        wah                          desc1                                                       desc2                                                       9900000004675                 0","Coefficient":"0","Secondary_Coefficient":"0","Multipl_Divisor":"","ReturnCode":"0","ReturnError":"Valid"}],"Items1":[{"ItemNo":"264","ItemCode":"01010111112","ItemDesc":"fil propylene transparent 

Open in new window

0
i have a json file, which contains KV pairs like below.

{
"app1_ds1_ds_jndi": "value1",
"app1_ds1_ds_url": "value2",
"app1_ds1_ds_useri": "value3",
"app1_ds1_ds_pwd": "value4",


"app1_ds2_ds_jndi": "value5",
"app1_ds2_ds_url": "value6",
"app1_ds2_ds_user": "value7",
"app1_ds2_ds_pwd": "value8",


"app2_ds1_ds_jndi": "value9",
"app2_ds1_ds_url": "value10",
"app2_ds1_ds_user": "value11",
"app2_ds1_ds_pwd": "value12",

}


I want to parse the above file to grep for all app1 datasources, ignoring other apps like app2, app3 ..etc., and construct an array of hashes in ruby like below.




[{jndiname: "value1",  url_name:"value2" user_name: "value3", Password:"value4"},
{jndiname: "value5",  url_name:"value6" user_name: "value7", Password:"value8"}
]
0
Dear sirs,
Please help, how can I avoid this exception. It happens when my http response includes an empty List in the body.

org.springframework.web.client.RestClientException: Error while extracting response for type [java.util.List<?>] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token at [Source: (PushbackInputStream); line: 1, column: 1] at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:115) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:991) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:974) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:725) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:698) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:649) at com.finger.services.AppRestTemplateService.doHandleListRequest(AppRestTemplateService.java:140) at

Please, assist
0
I am trying to make a request to Google Cloud NLP API to obtain sentiment analysis for a piece of text. I used Postman to design the correct request, and I was able to get a valid response using Postman. However, when I try to make the same request from Swift, it gives me an error. The error and code snippet used to make the request is shown below.

func sendAPIRequest(with text: String){

    print("Text: ", text)
    let jsonRequest = [
        [
        "document":[
            "type":"PLAIN_TEXT",
            "language": "EN",
            "content":"'Lawrence of Arabia' is a highly rated film biography about British Lieutenant T. E. Lawrence. Peter O'Toole plays Lawrence in the film."
        ],
        "encodingType":"UTF8"
    ]
        ]

    let jsonObject = JSON(jsonRequest)


    let headers: HTTPHeaders = [
        "X-Ios-Bundle-Identifier": "\(Bundle.main.bundleIdentifier ?? "") ",
        "Content-Type": "application/json"
    ]
    let APIRequest = Alamofire.request("https://language.googleapis.com/v1/documents:analyzeSentiment?key=\(gCloudAPIKey)", method: .post , parameters: jsonRequest as? [String: Any], encoding: JSONEncoding.default , headers: headers).responseJSON { (response) in
        print(response)
        if let json = response.result.value {
            print("JSON: \(json)")
        }
    }

Open in new window


Error:
JSON: {
error =     {
    code = 400;
    details =         (
                    {
            "@type" = "type.googleapis.com/google.rpc.BadRequest";
            fieldViolations =                 (
                                    {
                    description = "Must have some text content to annotate.";
                    field = "document.content";
                }
            );
        }
    );
    message = "One of content, or gcs_content_uri must be set.";
    status = "INVALID_ARGUMENT";
};
}

Open in new window

0

JSON

784

Solutions

785

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