JSON

982

Solutions

903

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

Hi experts!  I'm new to JSON and have a nested JSON that is being sent to my API.  I've attached the JSON file as well as my PHP trying to collect the values for the various "types" of lines.  While my code does not return any errors, the values that get input to my table are all "zeros" except for the "code", "rpt" and "zip" fields.  Can you help me with the correct structure to collect this data?JSON-request.docxPHP-Code.docx
0
Amazon Web Services
LVL 13
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.

On receiving data from a Json format from the RS 232 COM, I seem to have some a bit of a challenge, I have no problem in sending
(1)      I’m not sure at what point the received data (In Json string) from the gadget will  looped into  or iterated until passed through the table , I cannot see the actual connection here, my maths does not seem to balance. Kindly see if you can spot something here.
Below is the code requiring checking , currently there no errors whatsoever , but the connection on how that data which will be received will looped into the database that is where I’m behind.

Code requiring your attention

Private Sub CmdEmp_Click()
    Dim json As Object
    Dim i As Integer
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim item As Object
    Dim intPortID As Integer ' Ex. 1, 2, 3, 4 for COM1 - COM4
    Dim lngStatus As Long
    Dim strError  As String
    Dim strData   As String
    Dim lngSize As Integer
    ' Read maximum of 64 bytes from serial port.
    lngStatus = CommRead(intPortID, strData, 64)
    If lngStatus > 0 Then
        ' Process data.
    ElseIf lngStatus < 0 Then
        ' Handle error.
    End If

    ' Reset modem control lines.
    lngStatus = CommSetLine(intPortID, LINE_RTS, False)
    lngStatus = CommSetLine(intPortID, LINE_DTR, False)

    
    Set db = CurrentDb
    Set rs = db.OpenRecordset("Contact")
    
    i = 2
    For Each item In json
        
        With rs
            .AddNew
            ![id] = 

Open in new window

0
Hi All;

Im having the same error messages when sending data and receiving Json string using RS 232, before I start working on the gadget I want a second eye to  take a look on the code below, please  note the following :

9600 baud is converted to 64 bytes

All the  two codes for sending & receiving as well as for converting received data are called from the main code that has the data for sending since once the data is received by the gadget then the gadget is supposed to send a signature back instantly.

Receiving code


Private Sub CmdTaxReceive_Click()
Dim strData As String
Dim lngStatus As Long
Dim strError As String
Dim intPortID As Integer
' Read maximum of 64 bytes from serial port.
    lngStatus = CommRead(intPortID, strData, 64)

If lngStatus > 0 Then
        ' Process data.
 ElseIf lngStatus < 0 Then
      lngStatus = CommGetError(strError)
      MsgBox "COM Error: " & strError
      Stop
    End If
    
    lngStatus = CommFlush(intPortID)
    
    If lngStatus <> 0 Then
      lngStatus = CommGetError(strError)
      MsgBox "COM Error: " & strError
      Stop
    End If
' Reset modem control lines.
    lngStatus = CommSetLine(intPortID, LINE_RTS, False)
    lngStatus = CommSetLine(intPortID, LINE_DTR, False)
 ' Close communications.
    Call CommClose(intPortID)

End Sub

Open in new window

Sending code


Private Sub CmdSendTax_Click()
Dim intPortID As Integer ' Ex. 1, 2, 3, 4 for COM1 - COM4
    Dim lngStatus As Long
    Dim strError  As String
    Dim strData   As String
    Dim lngSize As Long

    ' Initialize Communications
    lngStatus = CommOpen(intPortID, "COM" & CStr(intPortID), _
        "baud=9600 parity=N data=8 stop=1")
    
    If lngStatus <> 0 Then
    ' Handle error.
        lngStatus = CommGetError(strError)
    MsgBox "COM Error: " & strError
    End If
 
    ' Set modem control lines.
    lngStatus = CommSetLine(intPortID, LINE_RTS, True)
    lngStatus = CommSetLine(intPortID, LINE_DTR, True)

    ' Write data to serial port.
    lngSize = Len(strData)
    lngStatus = CommWrite(intPortID, strData)
    If lngStatus <> lngSize Then
    ' Handle error.
    End If
End Sub

Open in new window



Calling them on the same form but on the main code


Call CmdTaxReceive_Click
Call CmdSendTax_Click
Call CmdEmp_Click

Open in new window



Where do I go wrong????



Auditing-tools.png


Blank-Invoices-Details.png
0
Dear all Experts!
I would like to thank you all for assisting me to almost finish my task as assigned by management, and many special thanks to Mr Jim for providing the VBA code below for send & receiving data from & to RS232 com gadget
The last bit though not much is another assistance required to receive the data from RS 232 which is coming in Json format, I’m fully aware he also provided a form on the scale part, but this appear to be slightly different:
Functional VBA Code:
Option Compare Database
Option Explicit

'-------------------------------------------------------------------------------
' modCOMM - Written by: David M. Hitchner
'
' This VB module is a collection of routines to perform serial port I/O without
' using the Microsoft Comm Control component.  This module uses the Windows API
' to perform the overlapped I/O operations necessary for serial communications.
'
' The routine can handle up to 4 serial ports which are identified with a
' Port ID.
'
' All routines (with the exception of CommRead and CommWrite) return an error
' code or 0 if no error occurs.  The routine CommGetError can be used to get
' the complete error message.
'-------------------------------------------------------------------------------

'-------------------------------------------------------------------------------
' Public Constants
'-------------------------------------------------------------------------------

' Output Control Lines (CommSetLine)
Public Const LINE_BREAK = 1

Open in new window

0
I need to insert a collection called Tax Class within Json format/Ms access VBA code which is now almost complete see current results below:

Current results
{
   "PosSerialNumber": "102010",
   "IssueTime": "2019-09-15",
   "Customer": 1,
   "TransactionTyp": 0,
   "PaymentMode": 0,
   "SaleType": 0,
   "Items": [
      {
         "ItemID": 1,
         "Description": "Apple (Rgb 350 ML)",
         "BarCode": "6009803227328",
         "Quantity": 15,
         "UnitPrice": 41,
         "Discount": 0,
         "Taxable": [
            {
               "Total": 615,
               "IsTaxInclusive": "True",
               "RRP": 52.8
            }
         ]
      },

Open in new window


Expected results

{
   "PosSerialNumber": "102010",
   "IssueTime": "2019-09-15",
   "Customer": 1,
   "TransactionTyp": 0,
   "PaymentMode": 0,
   "SaleType": 0,
   "Items": [
      {
         "ItemID": 1,
         "Description": "Apple (Rgb 350 ML)",
         "BarCode": "6009803227328",
         "Quantity": 15,
         "UnitPrice": 41,
         "Discount": 0,
         "Taxable": [
              "B"
               ]
            {
               "Total": 615,
               "IsTaxInclusive": "True",
               "RRP": 52.8
            }
         ]
      },

Open in new window

Amendment required on VBA

How do I include the new collection ("tax category") in the below VBA to hold ["B"] just below "taxable"

Private Sub CmdSales_Click()
  
'  Const SQL_SELECT As String = 

Open in new window

0
hi am having error in my script
python mapView.py
Traceback (most recent call last):
  File "mapView.py", line 44, in <module>
    style_function=lambda x: {'fillColor':'yellow'}))
  File "C:\ProgramData\Anaconda3\lib\site-packages\folium\features.py", line 450, in __init__
    self.data = self.process_data(data)
  File "C:\ProgramData\Anaconda3\lib\site-packages\folium\features.py", line 494, in process_data
    ': {!r}'.format(data))
ValueError: Cannot render objects with any missing geometries: <_io.TextIOWrapper name='world.json' mode='r' encoding='utf-8-sig'>
this my script
import folium
import pandas


data = pandas.read_csv("Volcanoes.txt")
lat = list(data["LAT"])
lon = list(data["LON"])
elev = list(data["ELEV"])




def color_producer(elevetion):
    if elevetion < 1000:
        return  'green'
    elif 1000 <= elevetion < 3000:
        return 'orange'
    else:
        return 'red'	


#map = folium.Map(location=[lat, lon], zoom_start=6, tiles="Stamen Terrain")
#map = folium.Map(location=[lat[0], lon[0]], zoom_start=5, tiles="Stamen Terrain")

map = folium.Map(location=[38.58,-99.09], zoom_start=5, tiles="Mapbox Bright")

#map = folium.Map(location=[0, 0], zoom_start=6)



fg = folium.FeatureGroup(name="My Map")

#for lt,ln,el in zip(lat,lon,elev):
 #    fg.add_child(folium.Marker(location=[lt, ln],popup=str(el)+" m",icon=folium.Icon(color=color_producer(el)))
	 
for lt,ln,el in zip(lat,lon,elev):
     

Open in new window

0
Hi,

I have the following json_decode data :

Array
(
    [metadata] => Array
        (
            [result] => 1
            [version] => 1
            [command] => listzones
            [reason] => OK
        )

    [data] => Array
        (
            [zone] => Array
                (
                    [0] => Array
                        (
                            [zonefile] => mybrand.asia.db
                            [domain] => mybrand.asia
                        )

                    [1] => Array
                        (
                            [domain] => mybrand.my
                            [zonefile] => mybrand.my.db
                        )

                )

        )

)

Open in new window


May i know how to manipulate the data ?

Eg:

1. How to get "mybrand.asia" or "mybrand.my.db" output ?

2. How to loop each data in foreach ?


Appreciates anyone assistant on this.

Thank you.
0
Now after puting the Json string correct in VBA Ms Access I'm required to send that string to a fisical device attached to my laptop using access rs232 port with vba is there any way to send data to com port or listen to it

Kindly help me with VBA , I really need your help over this:

(1) Setting up the VBA to use rs232 port and send data to a fiscal device
0
How to make sure the string picks the underlying value from a form in ms access vba, see below, the Json format returned is what is required , the problem the actual values are notr picked:

Option Compare Database
Option Explicit
Private Sub Command0_Click()
Dim Json As Object
Dim vals As String
Set Json = JsonConverter.ParseJson(CStr("{""Customer"":"" & Me.txtCustmer & "",""Location"":["" & Me.txta & "" ,"" & Me.txtb & "",  "" & Me.txtc & "","" & Me.txtd & ""],"" & Me.txtk & "":{""Quantity"":"" & Me.txtg & ""}}"))

' Json("a") -> 123
' Json("b")(2) -> 2
' Json("c")("d") -> 456

MsgBox JsonConverter.ConvertToJson(Json, Whitespace:=3), vbOKOnly, "Audited by Chris Hankwembo"
End Sub

Open in new window



See screen shoot


Auditing-tools.png
If this is done then that is it I will have more control on this.
0
Hi Experts!

After going through so many literature on the net to try and sort out this Json/Ms Access , I have come up with a much simpler version, see below:

Private Sub Command0_Click()
Dim Json As Object
Set Json = JsonConverter.ParseJson("{""a"":193,""d"":[1,8,7,4],""c"":{""d"":45}}")

MsgBox JsonConverter.ConvertToJson(Json, Whitespace:=3), vbOKOnly, "Audited by Chris Hankwembo"
End Sub 

Open in new window


Help required

Instead of using absolute values in the string above I want to use the form controls so that people can just select one detail for customer and the hidden form controls can be populated to feed this string:
Set Json = JsonConverter.ParseJson("{""a"":193,""d"":[1,8,7,4],""c"":{""d"":45}}")

Open in new window


(1) How I do it this way :
Json = JsonConverter.ParseJson("{""Customer"":""Me.txtCustmer"",""Location"":[Me.txta , Me.txtb,Me.txtc,Me.txtd],""Me.txtk"":{""Quantity"":Me.txG}}")

Open in new window


If the above is possible , then my problem is over. The rest I know what to do.


Regards

Chris
0
OWASP: Forgery and Phishing
LVL 13
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Kindly help me where I can buy a tutorial book (paper) for JSON/VBA Ms Access , clearly I'm lacking this important topic, I'm sure this group will be able to advise correctly.

Regards

Chris
0
Final touches required on the allocation of dictionary ({}) data & collection ([ ]) in Ms access VBA with Json, I can tell you this is troublesome because there is not enough tutorial out there.
Below is my final signed up requirements with management , I tried what I can, but to no avail, see how you assist here. A sample small database is also attached for easy reference

Many credits goes to Mr John helped me to reach this far , now just small touches required!

Final Approved structure by management :

{
"DistrictCode":"12563C",
"IssueTime":"2019-09-25",
"DocumentType":0,
"Status":0,
"Qualification":0,
"ProfessionBody":"5808863",
"Jobtitle":"SalesManager",
"CustomerCode":"WFG102563",
"BuyerName":"Clement & Sons"
"BankAccount":"FGH Bank",
"Address":"Rsv West"
"Telephon":"+256306903",
"BankCode":" ",
"Branch":" "
"Items":[
{
"Item":"1",
"BarCode":"6009803227328",
"Qty":"10",
"UnitPrice":41.50,
"Discount":0,
"Taxable":[
"B"
"Z"],
"TotalAmount":415,
"Inclusive":"True"
"ZGP":0
}
]
}

Open in new window



Amended VBA Function



Option Compare Database
Option Explicit

Public Function Invoices()
'  Const SQL_SELECT As String = "SELECT * FROM Qry3;"
  Dim json As String
  Dim coll As VBA.Collection
  Dim dict As Scripting.Dictionary
  Dim dictItems    As Scripting.Dictionary
  Dim db As DAO.Database
  Dim rs As DAO.Recordset
  Dim fld As DAO.Field
  Dim qdf As DAO.QueryDef
  Dim prm As DAO.Parameter
  Dim blnSubLevel As Boolean
  Set db = CurrentDb
  

Open in new window

0
Dear Experts!
Kindly see how you can help regarding fine tuning the generated json below:
[
  {
    "DistrictCode": "12563XC",
    "IssueTime": "2019-09-25",
    "DocumentType": 0,
    "Status": 0,
    "Qualification": 0,
    "ProfessionalBody": "5808863",
    "Jobtitle": "Chris",
    "CustomerCode": "WFG102563",
    "BuyerName": "Clement & Sons",
    "BankAccount": "FGH Bank",
    "Address": "Rsv West",
    "Telephon": "+256306903",
    "BankCode": "null",
    "Branch": "null",
    "ItemID": 1,
    "Description": "Pepsi (Rgb 350 ML)",
    "BarCode": "6009803227328",
    "Qty": 10,
    "Price": 41.5,
    "Discount": 0,
    "Tax": "T",
    "TotalAmount": 415,
    "Banker": "True",
    "Sp": 80.5,
    "DocumentDate": "2019-09-26"
  }
]

Open in new window

(1)      From DistrictCode to Branch + DocumentDate should go into { }
(2)      From item1 to Banker should go into [ ]
(3)      But Banker should be outside [

It seems their rules somewhere to apply on how to allocate items that belong to a dictionary & those belonging to collection, kindly share with me those rules if possible, I would not want to just rely on copy paste I want to learn this also.

Main function:


Option Compare Database
Option Explicit

Public Function Invoices()
'  Const SQL_SELECT As String = "SELECT * FROM Qry3;"
  Dim json As String
  Dim coll As VBA.Collection
  Dim dict As Scripting.Dictionary
  Dim db As DAO.Database
  Dim rs As DAO.Recordset
  Dim fld As DAO.Field
  Dim qdf As DAO.QueryDef
  Dim 

Open in new window

0
I have put the zip file from https://www.c-sharpcorner.com/article/pnp-people-picker-control-for-spfx/ into a webpart (after unzipping it). I'm trying to update my Sharepoint list.

With the PersonName field (Set as Person or Group in Sharepoint online) commented out it works. However when the PersonName field is not commented out it fails with this message. I followed the import instructions, but was wondering if my node modules directory is incorrect or if there is a difference between the Sharepoint used and my version of sharepoint online.

```
  @autobind 
 private addSelectedUsers(): void {  
 sp.web.lists.getByTitle("AlistairTest").items.add({
  Title: getGUID(),
  //With these lines commented out it works.  I changed the field name from User to PersonName when 
  //I created the column.
  PersonName: { 
      results: this.state.addUsers
  }
   }).then(i => {
    console.log(i);
   });
} 
```

Open in new window

Failed to load resource: the server responded with a status of 400 () [https://bhfonline.sharepoint.com/teams-and-projects/dev/halperna/_api/web/lists/getByTitle('AlistairTest')/items] Error: Error making HttpClient request in queryable [400] ::> {"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A node of type 'PrimitiveValue' was read from the JSON reader when trying to read the entries of a feed. A 'StartObject' or 'EndArray' node was expected."}}} at new HttpRequestError (d:\spfx-pnp-people-picker\dist\pn-p-people-picker-web-part.js:2364:29) at d:\spfx-pnp-people-picker\dist\pn-p-people-picker-web-part.js:2373:21
0
hi am having this error in angular
angular
0
I have a working code below for importing the Json data formatted into my database using VBA in Ms Access and below is the full code( The OPPOSITE CODE IS REQUIRED TO ARCHIEVE THE ORIGINAL JSON FORMAT IMPORTED , BUT NOW  UNDER EXPORT IS REQUIRED LINE BY LINE LIKE THE ONE BELOW :
Private Sub CmdEmp_Click()
    Dim http As Object
    Dim json As Object
    Dim i As Integer
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim item As Object
    Set http = CreateObject("MSXML2.XMLHTTP")
    Set db = CurrentDb
    Set rs = db.OpenRecordset("Contact")
    http.Open "GET", "http://jsonplaceholder.typicode.com/users/?id=" & Me.txtUserID, False
    http.send
    Set json = ParseJson(http.responseText)
    i = 2
    For Each item In json
        
        With rs
            .AddNew
            ![id] = item("id")
            ![firstName] = item("name")
            ![UserName] = item("username")
            ![email] = item("email")
            ![street] = item("address")("street")
            ![suite] = item("address")("suite")
            ![city] = item("address")("city")
            ![zipcode] = item("address")("zipcode")
            ![lat] = item("address")("geo")("lat")
            ![lng] = item("address")("geo")("lng")
            ![Phone] = item("phone")
            ![WebSite] = item("website")
            ![Company] = item("company")("name")
            ![catchPhrase] = item("company")("catchPhrase")
            ![bs] = item("company")("bs")
            .Update
  

Open in new window

0
I have researched this Json product in depth on how to create categories like the objects, arrays with headers, it requires to be done within the VBA code. Whichever programming language one decides to use the same thing must be done within the Code no matter what it takes.
Help required:
(1)      In seated of grouping the query recordset together as one set of category as per code below I want to allocate the query details controls according to categories:

Current query detail
For Each fld In rs.Fields
        dict.Add fld.Name, rs.Fields(fld.Name).Value
      Next fld

      coll.Add dict
      rs.MoveNext

Open in new window


Json example something like below:

“geo”:{
“lat”:”-37.50”
“lng”:”82”
}

Open in new window


In VBA code I want something like below:
Item(“geo”)(“lat”)(“lng”).

Open in new window


As you can see above “geo” must always remain as a category.

The main issue here, see the code below its treating all the record as if it belongs to one category which is incorrect, I want to add the controls from the select query below to the Json collection by control name so that I have an opportunity to categorize them according to the category they belong. For example, instead of using a code like:
For Each fld In rs.Fields
        dict.Add fld.Name, rs.Fields(fld.Name).Value
      Next fld

      coll.Add dict
      rs.MoveNext

Open in new window

I want to something like below:

With rs
            .AddNew
            ![street] = item("address")("street")
            ![city] = item("address")("city")
            ![zipcode] = item("address")("zipcode")
            ![lat] = item("address")("geo")("lat")
                      .Update
        End With

Open in new window


SELECT Qry3.CustomerName, Qry3.Address, ("Itmes") AS Items, Qry3.ItemID, Qry3.Description, Qry3.BarCode, Qry3.Qty, Qry3.UnitPrice, Qry3.Discount, Qry3.VAT, (([Qty]*[UnitPrice])) AS TotalAmount, Qry3.Exempt, Qry3.GGG, Qry3.DocumentDate
FROM Qry3;

Open in new window


If the above works, then I want the query details to look like the Json format below
{
“customerName”: “customerName”
“address”:”address”
“documentdate”:”documentdate”,
“Itmes”:[
{
“itemid”:”ItemId”
“Description”:”Description”
“Barcode”:”Barcode”
“Qty”:”Qty”
“unitprice”:”unitprice”
“discounts”:”discounts”
“vat”:”vat”
“totalamount”:”totalamount”
“exempt”:”exempt”
“ggg”:”ggg”,
]
}

Open in new window

Full VBA require amendments on the recordset and addition to the Json collect:


Open in new window

0
I'm using Postman to proof my authentication script and it's working great!

My question is what does an actual request look like in the context of something other than Postman? In other words, how does one embed a JWT in the header?

Would it look something like this:

<html>
  <head>
    <meta http-equiv="content-type" content="application/json" />
   Authorization: Bearer <secretkey>
   </head>
</html>

Open in new window


Maybe another way to phrase the question is, "What does the function of Postman look like in the context of an actual page?"
0
Dear All;

Sorry I thought putting header was just simple in json converted data , but has proved to destroy all my effort so far . I'm now required to rearrange the Json data from screen shoot below to have the following:

(1) The customer name & address MUST only appear on top of the receipt NOT on every item.
(2) List of products must have category called ITEMS


Example

{
"Customer": "J j Zingalume ",
"Address": "Lusaka West",
"Items:[
{
  "Item":"1"
 "Description": "Rice"
"Quantity":"10"
"UnitPrice":"51"
"Total":"510"
}
]
}

Open in new window

Kindly note that Im using the Json converter in  Ms Access, that is why I have these challenges.


DataArrangements.png
0
Exploring SharePoint 2016
LVL 13
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.

After going through Ms Access VBA  line by line to try and discover why my posting is not  being recorded on the fake web site I have discovered a clear error  on

 Set JSON = ParseJson(http.responseText)

Open in new window


See my full code here:

Private Sub CmdSales_Click()
  
'  Const SQL_SELECT As String = "SELECT * FROM Qry3;"
  Dim http As Object
  Dim JSON As Object
  Dim coll As VBA.Collection
  Dim dict As Scripting.Dictionary
  Dim db As DAO.Database
  Dim rs As DAO.Recordset
  Dim fld As DAO.Field
  Dim qdf As DAO.QueryDef
  Dim prm As DAO.Parameter
  Set http = CreateObject("MSXML2.XMLHTTP")
  Set db = CurrentDb
  Set qdf = db.QueryDefs("Qry4")
  http.Open "POST", "http://jsonplaceholder.typicode.com/comments, False"
  http.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
  http.setRequestHeader "Content-type", "application/Json"
  http.send ("ConvertToJson(coll, Whitespace:=3)")
  Set JSON = ParseJson(http.responseText)
For Each prm In qdf.Parameters
    prm = Eval(prm.Name)
Next prm
Set rs = qdf.OpenRecordset()

Set qdf = Nothing
  Set coll = New VBA.Collection
'  Set db = CurrentDb
'  Set rs = db.OpenRecordset(SQL_SELECT, dbOpenSnapshot)
  If Not rs.BOF And Not rs.EOF Then
    Do While Not rs.EOF
      Set dict = New Scripting.Dictionary
      For Each fld In rs.Fields
        dict.Add fld.Name, rs.Fields(fld.Name).Value
      Next fld

      coll.Add dict
      rs.MoveNext
    Loop
  End If

  rs.Close
  Set fld = 

Open in new window

0
I have a python script on python 3.7.2 that I have pieced together. The script will first accept user input for a string and store into a variable and then iterate through each function call.

Depicted here:

while True:
    uin = input("Please enter a uin or 'enter' to quit: ")
    if not uin:
        break
    startTime = datetime.now()
    selectCustomer(uin)
    selectVehicle(uin)
    selectHRO(uin)
    selectHLABOR(uin)
    selectHPARTS(uin)
    selectINV(uin)
    selectSUPPLIER(uin)
    selectLABOR_OP(uin)
    selectSOURCE(uin)
    selectRO(uin)
    selectLABOR(uin)
    selectPARTS(uin)
    selectEHRO(uin)
    selectEHLABOR(uin)
    selectEHPARTS(uin)
    endTime = datetime.now() - startTime
    print('It took', endTime, ' seconds to run...')

Open in new window


Each function (for the most part is exactly identical and is composed of:

  • opening up a SQL connection
  • running a query
  • storing the output in an ordered dictionary
  • creating a JSON file and naming it with the user input (in our case UIN)
  • closing connection and file

Depicted here:

def selectEHPARTS(uin, output_dir=r"C:\Code\TestData"):
    driver = 'DRIVER={SQL Server};'
    host = 'SERVER=SQL2;'
    database = 'DATABASE=ROWSTAGE;'

    connectionstr = driver + host + database
    conn = pyodbc.connect(connectionstr)
    cursor = conn.cursor()

    cursor.execute("SELECT STORE_UIN, RO_NO, PARTNO, PARTDESC, ITEM_NO, 

Open in new window

0
Hi, I have a PHP script which calls another PHP script via a jQuery ajax call.  I can see that the call is successful and that there is a proper response from the network activity.  However I am having trouble processing that response in the calling PHP/JavaScript code.

Here's my attempt:

demo.html

From the network activity I see the response is:

["data1","data2"] and this is what I am expecting (actual data not shown)

But I cannot 'see' nor process these data in the success data in the calling code shown above.  The alerts do not fire.

Any guidance will be most appreciated and thank you in anticipation.
0
What version of SQL Server introduced JSON support?  
For some reason I'm not finding it any of the JSON docs.microsoft.com pages.

Thanks in advance.
Jim
0
We are now required to process the invoices from Ms Access and then transfer the invoices details to the tax authority in Json format , fair enough . All is okay except the date is always behind by a day after using the Json converter below.

(1) I have attached the screen shoot for the actual invoice dated 13/09/2019 and the converted data into Json, Kindly check the DATE it is always behind by 1 day. Is there a way to sort out this?


'
VBA-JSON v2.3.1
' (c) Tim Hall - https://github.com/VBA-tools/VBA-JSON
'
' JSON Converter for VBA
'
' Errors:
' 10001 - JSON parse error
'
' @class JsonConverter
' @author tim.hall.engr@gmail.com
' @license MIT (http://www.opensource.org/licenses/mit-license.php)
'' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
'
' Based originally on vba-json (with extensive changes)
' BSD license included below
'
' JSONLib, http://code.google.com/p/vba-json/
'
' Copyright (c) 2013, Ryo Yokoyama
' All rights reserved.
'
' Redistribution and use in source and binary forms, with or without
' modification, are permitted provided that the following conditions are met:
'     * Redistributions of source code must retain the above copyright
'       notice, this list of conditions and the following disclaimer.
'     * Redistributions in binary form must reproduce the above copyright
'       notice, this list of conditions and the following disclaimer in the
'       documentation and/or other materials provided with the 

Open in new window

0
I have the following json string. how  to read it in c# FOR  LOOP?

{Employee:[{"principalfirstname":"xxx","principallastname":"xxx","principalmiddlename":"xxx","principalnameonbond":"xxx","principaldba":"xxx","principalentity":"USA","principalyearinbusiness":"xxx","principaltaxid":"","principaladdress":"xx","principalcity":"xxx","principalstate":"TN","principalzip":"111","principalcounty":"","principalphoneno":"xxx","principalemail":"","principalfaxno":"","vin":"","licenseplatenumber":"","driverlicensenumber":"","door":"","bondstate":"","bondamount":"","premium":"","bondterm":"","creditcardfullname":"","creditcardnumber":"55555555533331111","creditcardchargeamount":"","creditcardexpdatemm":"","creditcardexpdateyyyy":"","creditcardcvc":"","creditcardaddress":"","creditcardcity":"","creditcardstate":"","creditcardzip":""}]}

Open in new window

0

JSON

982

Solutions

903

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.