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

x

JSON

802

Solutions

810

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

Is this code convertible to print it's results to a txt file, instead of to a JSON ?curl object? We are trying to debug a specific sku and we want to see the output of the long query which precedes this snippet:

         foreach($group_sets AS $group_set) {
            $bulk_json .= '{ "index" : { "_id" : "'.$group_set['our_sku'].'" } }'.PHP_EOL;
            $bulk_json .= json_encode($group_set).PHP_EOL;   
         }	
         foreach($remove_skus AS $sku) {
            $bulk_json .= '{ "delete" : { "_id" : "'.$sku.'" } }'.PHP_EOL;     	     
         }
         print "processing batch, batch count: ".$batch_cnt.PHP_EOL;
         send_to_elastic($bulk_json);
         $bulk_json = ""; 
         $batch_cnt = 0;
         $batch_sku_list = array();
      }
   }
   if(!empty($bulk_json)) {
      send_to_elastic($bulk_json);
      $bulk_json = ""; 
   }

   print PHP_EOL.PHP_EOL."DONE".PHP_EOL.PHP_EOL;
      
   function send_to_elastic($bulk_json) {
         $url = "https://ada64ff1913a4b.us-east-1.aws.found.io:9243/us/product/_bulk";


         $curl = curl_init($url);
         curl_setopt($curl, CURLOPT_HEADER, false);
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($curl, CURLOPT_USERPWD, "MyName:MyPassword");
         curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
         curl_setopt($curl, CURLOPT_POST, true);
         curl_setopt($curl, CURLOPT_POSTFIELDS, $bulk_json);

         echo "uploading 

Open in new window

0
Fundamentals of JavaScript
LVL 12
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

I am trying to print labels using a DYMO Developer SDK it uses javascripts here is my files PrintMeThatLabel2.js

I got most of it working with the help for you all. I have a from the user query sql then save the info to a json then the PrintMeThatLabel2.js get that info and prints the label. If the query get 10 recorded it prints 10 labels Great!


But if I want to print 1 label out of the 10 I don't know how to push the 1 json to the PrintMeThatLabel2.js for printing.


I got most of it working so when I press Print me button it reloads the json array with just 1 recorded then I have to click the big print button at the top to print just that 1 recorded.

If the user then want to print them ALL 10 he/she will have to query the db again for it to load all the recorded in to the json array then click the big print button to run PrintMeThatLabel2.js and print.

I am trying to not have the user rerun the page to print all label ones the just pick one of the record to print.


so 2 buttons 1 prints all the recorded and 1 prints just the one he/she picked.

Most of you will recognize this code

<html>
<head>
<title>Search</title>

<link rel="stylesheet" type="text/css" href="PrintMeThatLabel.css" />
<script src = "cookie.js" type="text/javascript"> </script>

<script src="https://code.jquery.com/jquery-3.1.0.js"></script>

<script src = "http://www.labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.3.0.js" type="text/javascript" charset="UTF-8">

Open in new window

0
 // New temperature readings - 0 ~ 100C
    temp_value = analogRead(ANALOG_PIN_0);
    temp_value = (temp_value/4096) * 100;

    // New temperature readings - 0 ~ 300 PSI
    press_value = analogRead(ANALOG_PIN_1);
    press_value = (press_value/4096) * 300;
    
    void GET_METER() {     // Update read all data
       delay(1000);                             
       for (char i = 0; i < Total_of_Reg ; i++){
           DATA_METER [i] = Read_Meter_float(ID_meter, Reg_addr[i]);// ID_METER_ALL=X
       } 
   }

Open in new window

 
//New EnergyData
   Data_meter[0] = 241.25        //voltage
   Data_meter[1] = 3.53            //Ampere
   Data_meter[2] = 49.1            //kw
   Data_meter[3] = 0.98           //pf
   Data_meter[4] = 49.99         //freq
   Data_meter[5] = 120.58      //kw

   temp_value = 55.3                //Celsius
   press_value = 300.1             //pressure in psi


I am looking forward to send data in jason format. Referring to my code: -

data_send = "{
                              "temp_value" : 55.3,              
                              "press_value": 300.1,
                              "Voltage" : 241.25,
                              "Ampere": 3.53,
                              "KW": 49.1,
                              "pf": 0.98,
                              "freq": 49.99,
                             "kw":120.58
}"

How to convert data_send into string format.
0
I would like to read JSON URL link from SQL SERVER. I would like to build a stored procedure by passing JSON URL Link and would like to store output into a SQL SERVER table.
0
how to use copyright symbol and trad mark symbol in rest api call (I need to pass  one of the Json parameter )

I need to get it in Java code and save the values in DB .

Any one have idea on this ??
0
Searching though a JSON with php and jquery

I have some code that querys a DB with php and put the info in a json array here is my code


<html>
<head>
<title>Search</title>
<link rel="stylesheet" type="text/css" href="PrintMeThatLabel.css" />
<script src = "cookie.js" type="text/javascript"> </script>

<script src = "jquery-1.4.3.min.js" type="text/javascript"> </script>
<script src = "http://www.labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.3.0.js" type="text/javascript" charset="UTF-8"> </script>
<script src = "PrintMeThatLabel2.js" type="text/javascript" charset="UTF-8"> </script>
<style type=text/css>

.text {color: #000; font-family:Arial, Helvetica, sans-serif }
.head {color: #000; font-family:Arial, Helvetica, sans-serif }
.input {display:none;}



.tftable {font-size:12px;color:#333333;width:100%;border-width: 1px;border-color: #729ea5;border-collapse: collapse;}
.tftable th {font-size:12px;background-color:#acc8cc;border-width: 1px;padding: 8px;border-style: solid;border-color: #729ea5;text-align:left;}
.tftable tr {background-color:#d4e3e5;}
.tftable td {font-size:12px;border-width: 1px;padding: 8px;border-style: solid;border-color: #729ea5;}
.tftable tr:hover {background-color:#ffffff;}




</style>

</head>
<body>


    <div class=text align="center">

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" >

<span class=text>Enter Work Order #: </span>
<input type="text"  name="Work_Order" length="30"  value="">


<input 

Open in new window

0
javaScript

I have a JSON array passed back to javaScript from a PHP / MS-SQL table extraction.   The table has 100 fields and 2,000 records so the JSON array has 100 "key":"value" pairs and 2,000 rows.

From this JSON array In javaScript, I would like to create another JSON array of all 2,000 rows from it, but with only 2 of its 100 key:value pairs. These two for example (ItemCode and ItemName):

{"ItemCode" : "1234567", "ItemName" : "Widget", "...." : "....", }, { .... }

How can I do that in javaScript?


Another question:

How can I do it being sure there are no duplicates of the 2 key:value pairs in the new array?
0
I am trying feed a json to a Dymo printer for labels. I found some old doc on it here  
I want to use Option 2

Put I don't know how to import my json array in there code. On Line 30 is my Var mike it's getting the json array from a input box I used to store it. The json array is this

[{"Barcode ":"M125942-002","part ":"F06984-0027","DESCR":"BACC69CCC0027J\/BOEIN, REV R","MFG":"M125942-002","Cable_Length":"27.125 Inches","Test_A":"0.03","Test_B":"0.05"},{"Barcode ":"M125942-003","part ":"F06984-0027","DESCR":"BACC69CCC0027J\/BOEIN, REV R","MFG":"M125942-003","Cable_Length":"27.125 Inches","Test_A":"0.06","Test_B":"0.04"}]

Open in new window


There are only 2 labels I know the Dymo being used only has 1 text field I will be making my own label and adding the xml to this file when it's done. I just need help in importing the json in to this so then I can use it's fields to feed the label.




//----------------------------------------------------------------------------
//
//  $Id: GoogleSpreadSheet.js 38773 2015-09-17 11:45:41Z nmikalko $ 
//
// Project -------------------------------------------------------------------
//
//  DYMO Label Framework
//
// Content -------------------------------------------------------------------
//
//  DYMO Label Framework JavaScript Library Samples: 
//    Print mulltiple labels using Google Spreadsheet as a data 

Open in new window

0
How to export all my data in to a json array

Here is my code

<?php
ini_set('display_errors', TRUE);
error_reporting(E_ALL);


if(isset($_POST['submit']))
{


$UsrWorkOrder = $_POST['Work_Order'];


//db connect info
include 'conn.php';
//Where the query are stored 
include 'Query.php';




$result_Vis = odbc_exec($conn_Vis,$sql_Vis);  // Get Data From Result
    while($row2 = odbc_fetch_array($result_Vis))
    {
//Store the data in the new array

 

            $result_cor1db01_2 = odbc_exec($conn_cor1db01_2,$sql_cor1db01_2);  // Get Data From Result

            while($row3 = odbc_fetch_array($result_cor1db01_2))
            {







//This stores the data 
            	$Barcode = $row3["Work Order No"]."-". $row3["Serial No"];
       			$part = $row2["PART_X"];
        		$DESCR = $row2["DESCR_X"];
            	$Cable_Length = $row3["ValueInches"];
            	$MFG = $row3["Work Order No"]."-". $row3["Serial No"];
            	$Test_A = number_format($row3["Value1"],2);
            	$Test_B = number_format($row3["Value2"],2);



                    Echo "<br><br><img src=barcode.php?codetype=Code128B&size=80&text=".$row3["Work Order No"]."-". $row3["Serial No"] ." />";
                    Echo "<br>".$row3["Work Order No"]."-". $row3["Serial No"]."<br>";
                    Echo "Part Number: ".$part."<br>";
                    Echo "Description: " .$DESCR."<br>";
                    Echo "Mfg Lot Number: " .$row3["Work Order No"]."-". $row3["Serial 

Open in new window

0
hi,

error when running python script to remove VM from the output JSON file. Thanks

# nano destroy_all_vms.py
# python destroy_all_vms.py
/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:769: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
  InsecureRequestWarning)
Traceback (most recent call last):
  File "destroy_all_vms.py", line 29, in <module>
    res = delete_vm(vm_id, access_token)
NameError: name 'vm_id' is not defined

delete python script

from fusion import delete_volume
from fusion import delete_vm
from fusion import get_token
import json
import os
from time import sleep
from os.path import isfile, join

mypath = 'outputs'
time_delay = 20

## get all files inside hte outputs directory
onlyfiles = [f for f in os.listdir(mypath) if (isfile(join(mypath, f)) and (f.find('.json') > 0) )]

if len(onlyfiles) > 0:
    access_token = get_token()

for f in onlyfiles:
    vm_file_path = "outputs/" + f

    with open(vm_file_path) as vm_file:
        vm_data = json.load(vm_file)
        for vm in vm_data:
            volume_id = vm['volume_id']

            ## TODO: Check for the existence of the
            ## VM and volume and move forward

            res = delete_vm(vm_id, access_token)
            if res:
                print("Deleted {0} VM successfully.".format(vm['name']))

       …
0
Become a Certified Penetration Testing Engineer
LVL 12
Become a Certified Penetration Testing Engineer

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.

I am trying to use JSON data from my local site and it appears to not load.  The format of the JSON is in the following format:

[{"id":"5bf300018asdfdsasdf","cpuUser":"2.12df","cpuLoader":"3.00212","netTotText":null}]

I am unable to see it as data on my web page even though in it's raw form on the web page, it seems to work.  What can I do to resolve this issue?  Thank you!
0
I'm trying to pull some data from an API with JSON into an SQL 2016 DB. However if the data in one of the fields contains a hyphen it causes the query to fail. How do I solve this?
Thank you
Code:
declare @JSON nvarchar(max) = '[{"id":1,"preferredName":"James","surname":"Brown-Smith"}]'
Merge INTO TblStaff as TARGET 
using(SELECT * FROM OPENJSON(@json) WITH ( 
surname NVARCHAR(MAX) '$.surname', 
preferredName NVARCHAR(MAX) '$.preferredName', 
id INT '$.id' 
)) as SOURCE on TARGET.intStaffID=SOURCE.id when matched then update set TARGET.txtSurname=SOURCE.surname, TARGET.txtPrename=SOURCE.preferredName, TARGET.intStaffID=SOURCE.id 
WHEN NOT MATCHED BY TARGET THEN insert (txtSurname, txtPrename, intStaffID) values (SOURCE.surname,SOURCE.preferredName,SOURCE.id) ; 

Open in new window

0
Using JsonResult causes the form submission to ask the user if they want to download the json file?

My controller is:

 [HttpGet]
        public ActionResult Edit(int id)
        {
         
            tbl_MyTable tbl = (from x in DB.MyTable
                             where x.ID == id
                             select x).Single();

            return View(edit);

        }

[HttpPost]
        public JsonResult Edit(List<newList> formData)
        {
            var result = new { Success = "", Message = "" };
            try
            {
                   foreach (var item in formData)
                {
                    tbl_MyTable  Data = (from x in DB.tbl_MyTable
                                             where x.ID == item.ID
                                             select x).Single();

                    Data.Type = item.Type;
                    Data.Name = item.Name;
                    Data.Version = item.Version;
                    Date = item.Date;
                }

                DB.SaveChanges();
                TempData["msg"] = "<script>swal('Item successfully updated!');</script>";

            }

            catch (Exception ex)
            {
                Utility util = new Utility();
                string error = util.innerExcep(ex);
                result = new { Success = "False", Message = error };
                return Json(result);
            }

            result = new { Success = …
0
i have developed an app for android which stores a serialized domain model in a json file to the local storage. Now the thing is, sometimes i make changes to the domain model (new features) and want to have the option to **easily** load a previous structure of the json file from the local storage. How can i do this?

I thought of deserializing the object anonymously and use auto-mapper, but i want to hear other's opinions first before going this path.

If a code example of the domain model is needed (before and after), i'll provide. Thanks everyone.
0
I want to write a web page that requests an xml or json request every hour from another site and then parse and update fields
I have written general pages that are static in nature, but now I want to write on that auto updates every how with new data pulled from another site which returns the data in either json or xml.
I am not sure how I would do this.
I am looking for some basic samples or a good tutorial for this type of action.

Thanks, Bruce
0
For some reason, maybe due to schema or lack thereof, my JSON documents are flagged with "Unexpected character sequence in member name".

And also, the member names do not have quotes around them when I first open the document, but then either through process of saving or modifying the documents, the member names get surrounded with double-quotes.

 View: "vAnnouncements",

becomes:

"View": "vAnnouncements",

I could use some help with this!

I just recently ran "Get Latest" from the TFS, so the double-quotes problem corrected as a result.  But I am still getting the "Unexpected character" thing.
     

-Tom
0
I am trying to use Angular 7's drag and drop cdk to drag and drop mat-card. My code is quite complicated. I am creating mat-grid dynamically according to grid number (Raster is the property in JSON for this - in German). I want to just change the mat-card embedded in tile but when I drag one card from one place to another, entire layout of my grid changes. I dont want this. I just want to change the card from one postion to another. Below is my code.

Raster.component.html

<mat-grid-list cdkDropList class="example-list z-depth-5" cols="3" rowHeight="180px" gutterSize="8px" (cdkDropListDropped)="drop($event)">
  <mat-grid-tile class="example-box z-depth-4" *ngFor="let tile of tiles; let i = index" [colspan]="tile.cols" [rowspan]="tile.rows" cdkDrag>
    <mat-card class="add-new-flyer" *ngIf="tile.flyer == '-1'" id="p_{{tile.flyer}}">
      <div fxLayout="row" fxLayout.xs="column" fxLayoutWrap fxLayoutAlign="space-evenly">
        <div fxLayout fxLayout fxLayout.xs="column" fxLayoutAlign="end" fxLayoutGap="10px" fxLayoutGap.xs="0">
          <div class="button">
            <button mat-mini-fab (click)="addNewWerbedata(tile.text)">
              <mat-icon>add</mat-icon>
            </button>
          </div>
        </div>
      </div>
    </mat-card>
    <mat-card class="flyer-card" *ngIf="tile.flyer !== '-1'" id="p_{{tile.text}}">
      <div class="container" fxLayout fxLayout.xs="column" fxLayoutAlign="left" fxLayoutGap="10px" fxLayoutGap.xs="0">
        <div 

Open in new window

0
I Have this JSON
[{"uuid":"ead6b1c6-700c-446b-a96d-4809a00ba119","name":"BECCOFINO","created_at":"2017-05-08 09:26:07","updated_at":"2018-09-18 15:35:10","deleted_at":null,"levels":{"level2":[{"type":"F&B","uuid":"d7dc52f6-8b94-4ae2-9d7e-9e72b1f03853","name":"Beccofino","created_at":"2018-09-18 15:33:58",      "updated_at":"2018-09-18 15:42:21","deleted_at":"2018-09-18 15:42:21","customer_uuid":"ead6b1c6-700c-446b-a96d-4809a00ba119"},{"type":"Con_tact","uuid":"f7c4c881-88cb-433c-9bd7-9057fe8239d3","name":"Andrea Rotolli","created_at":"2018-09-18 15:38:08","updated_at":"2018-09-18 15:42:08","deleted_at":"2018-09-18 15:42:08","surname":"Rotolli","forename":"Andrea",      "prop_Gender":"Male","prop_Seize":"UXXXL","customer_uuid":"ead6b1c6-700c-446b-a96d-4809a00ba119"}]},"categories":["Auto Return","Available in Track"],"sync":"customer"}]

with these classes
    Public Class cls_JSON_Levels_Header_New
        Public uuid As String
        Public name As String
        Public created_at As String
        Public updated_at As String
        Public deleted_at As String
        Public levels() As cls_JSON_Levels_Body
        Public categories() As String
        Public sync As String
    End Class

    Public Class cls_JSON_Levels_Body
        Public level2() As cls_JSON_Level_Details
        Public level3() As cls_JSON_Level_Details
    End Class

    Public Class cls_JSON_Level_Details
        Public type As String
        Public uuid As String
        Public name As …
0
I have a public API endpoint that I am pulling a json file every 30 mins. Right now I am using a python pandas dataframe to pull and upload the file to a cloud storage bucket and then sending to pub sub to process and place into BQ. The problem with this is that the file name stays the same and even though I have  gcs text stream to pub sub if it reads the file once it never reads it again even though the file attributes have changed. My question here is can any one help me with code that will pull from an api web link and stream the data directly to pub sub?

Sample code below:
import json
import pandas as pd
from sodapy import Socrata
from io import StringIO
import datalab.storage as gcs
from google.oauth2 import service_account

client = Socrata("sample.org", None)
results = client.get("xxx")

# Convert to pandas DataFrame
results_df = pd.DataFrame.from_records(results, columns =['segmentid','street','_direction','_fromst','_tost','_length','_strheading','_comments','start_lon','_lif_lat','lit_lon','_lit_lat','_traffic','_last_updt'])
# send results to GCP
gcs.Bucket('test-temp').item('data.json').write_to(results_df.to_json(orient='records', lines=True),'text/json')
0
Amazon Web Services
LVL 12
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Google Elevation API
The article's main focus is , to create a C# console application using Google's Elevation API. For more detailed information about this topic, use the attached links.
0
Hello Expert,

Could anybody please through light on following query. How json table works here !

SELECT ext.legacy_id        legacy_id,
                               ext.record_type      record_type,
                               ext.tran_type        tran_type,
                               ext.corp_id          corp_id,
                               ext.mdse_co_id       mdse_co_id,
                               json.loc             location,
                               ext.sty_cd           sty_cd,
                               ext.sty_clr_cd       sty_clr_cd,
                               ext.mkt_cd           mkt_cd,
                               ext.unit_price       unit_price,
                               ext.effective_date   effective_date
                          FROM risprc.ris_legacy_price_stg ext,
                               json_table('['||ext.excep_str_nbr||']', '$[*]' COLUMNS loc  NUMBER PATH '$') json,   --How it works?
                               TABLE (CAST (L_loc_tbl AS NUMBER_TBL)) tbl
                         WHERE ext.record_type   = LP_corp_rec_type
                           AND ext.excep_str_nbr IS NOT NULL
                           AND ext.location      = VALUE(tbl) ;

Open in new window

0

MySQL 5.7 and the JSON data type, Help with basic 3 basic functions / queries


I have a data structure I am trying to work with in experimenting and doing a proof of concept using the JSON data type in MySQL. I am using node.js for my back end.

Here is my table syntax
DROP TABLE if exists user;
CREATE TABLE user (
  `id` varchar(128) NOT NULL,
	`device_id` varchar(128) NOT NULL,
  `email` varchar(100) DEFAULT NULL,
	`device_type` enum('','android','ios','web') DEFAULT NULL,
  `password` varchar(512) DEFAULT NULL,
  `login_by` enum('manual','facebook','anon') DEFAULT 'anon',
  `created_timestamp` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `modified_timestamp` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `data` json NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `device_id` (`device_id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Open in new window


This what I want my JSON data object to look like
{
  "name": "Allen",
  "albums": []
}

Open in new window

Issue 1.

When I create a user this is the query being executed. It is formatted as it is by node to actually run. This is based on the documentation I have seen

insert into user (id, device_id, device_type, data ) values ("39c48d40-de07-11e8-9d18-518c0c9d3ee2","this4","ios",'{"name": "allen", "albums": []}')

Open in new window

This works however creates a string in the JSON data type. I thought the data type was supposed to be binary
If I do a
select * from user 

Open in new window

then my results will return the JSON object as a string I need to parse.
{
        "id": "39c48d40-de07-11e8-9d18-518c0c9d3ee9",
        "device_id": "this3",
        "email": null,
        "device_type": "ios",
        "password": null,
        "login_by": "anon",
        "created_timestamp": "2018-11-01 14:52:05",
        "modified_timestamp": "2018-11-01 14:52:05",
        "data": "{\"name\": \"Allen\", \"albums\": []}"
    }

Open in new window


If I try to put in straight JSON Object like this I get a SQL error.
insert into user (id, device_id, device_type, data ) values ("39c48d40-de07-11e8-9d18-518c0c9d3ee9","this4","ios",{"name": "allen", "likes": []})

Open in new window

Question
How do I create the JSON data type that is binary and not a serialized string.

Issue 2

This is related to issue one.
I am hoping to add an object to the array for albums
This query worked but with issues
UPDATE user SET data = JSON_ARRAY_APPEND( `data` , '$.albums' , '{"id":"sd123asdwe","title":"OU812"}' ) WHERE id = "39c48d40-de07-11e8-9d18-518c0c9d3ee9"

Open in new window


It added an additional serialized string to the overall object, so now when I get my data I need to parse the json, then loop through the array and parse the individual items..

Open in new window

0
I am trying to read in a JSON  stream and able to use it to look up the datatype of a property. please see below.
What do I need to call using JSON.net to structure a proper lookup of an array of elements,  Below is a summary what I would like to do:
1. Lookup to see if there is a match of one of the following keyword:- 'Device/AnalogInput/AnalogOutput ...'.  This list can vary at runtime hence I can not write a class for each keyword
2. if exist,  loop through the property to find out the data type of each property
For example
I check if there is a keyword called 'Device',  Once I find it exists, I would like to loop through to find the 'datatype' of each property. In this case, I would find out 'datatype' of property 'SystemStatus' is 'int'. Next, I would find out 'datatype' of property 'ObjectName' is 'string'.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Data;


namespace TestJSONLookup
{
    class Program
    {
        static void Main(string[] args)
        {
            string json = @"[
  {
    'Device': [
      {
        'property': 'SystemStatus',
        'dataType': 'int'
      },
      {
        'property': 'ObjectName',
        'dataType': 'string'
      }
    ]
  },
  {
    'AnalogInput': [
      {
        'property': 'PresentValue',
        'type': 'real'
      }
    ]
  },
  {
    'AnalogOutput' : [
      {
    

Open in new window

0
Hi Experts,
My getting following Error Message

"ie.Message      "Object reference not set to an instance of an object."      string"

Any help appriciated.
See my code below

public class SalesRecords
    {

        public List<salesProp> data { get; set; }

    }




  public class salesProp
    {
        public string Name { get; set; }  
    }  





    var  restunVal1=response.Content.ReadAsStringAsync().Result;

   SalesRecords  sr = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<SalesRecords>(restunVal1);

                     foreach (var item in sr.data)
                     {
                         Console.WriteLine("id: {0}",item.Name);
                     }





JSON output like this
"{\n  \"totalSize\" : 1,\n  \"done\" : true,\n  \"records\" : [ {\n    \"attributes\" : {\n      \"type\" : \"Account\",\n      \"url\" : \"/services/data/v40.0/sobjects/Account/0011q000007ZPL3AAO\"\n    },\n    \"Name\" : \"Test\"\n  } ]\n}"
0
Migrating Oracle procedures which has JSON data as input and business validation to insert/ update/delete tables to MariaDB.

Can we use SQL_MODE to ORACLE and use the same procedure ? Or we need to rewrite it again.

Like few differences where we use JSON_PARSER.PARSER(<<my input JSON>>) or JSON_EXT.GET_NUMBER / JSON_EXT.GET_STRING in Oracle to get the values for specific keys. So can we directly use the same procedure to work on Mariadb by setting the mode or we need to rewrite the entire procedure.
0

JSON

802

Solutions

810

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