Triggered by this question:
https://www.wix.com/corvid/forum/community-discussion/wix-bookings-api-paymenttype-wixpay-offline-not-working-in-checkoutbooking-function
I dug a bit deeper into the difference of JS Objects and JSON, especially the notation of the Identifier in both (I never did, never occurred to me, to be honest).
SO far, I found out that:
JS Object Identifiers MAY BE unquoted
JS Object Identifiers and Values (strings) MAY BE single quoted
JSON Identifiers MUST BE double quoted.
Where it starts to get fuzzy to me is when I look at the Corvid doc. Given the fact that JSON is a data-exchange format, one would expect ALL data exchange to be JSON, thus double quoted.
BUt in doc about wix-bookings Booking Info it states:
"BookingInfo
An object used when calling checkoutBooking() containing information about the slot to be booked."
Since JSON HAS no objects, just strings, I would expect the “object” to be allowed to be unquoted. But in the example it IS quoted:
let bookingInfo = {
"slot": chosenSlot,
"formFields": formFieldValues
};
But in wix-pay (backend function, which must do some data transfer with a payment provider), the example code is unquoted:
export function createMyPayment() {
return wixPay.createPayment({
items: [{
name: "Product Name",
price: 9.99
}],
amount: 9.99
});
}
So my question is:
- if Corvid docs uses double quoted Identifiers, may we assume this is JSON, or could it sometimes be the alternative notation for JS Objects? In other words, is it consistent?
- what I do not understand is why wix-pay (backend) works unquoted, vs, the wix-booking´s double quoted example: both do data transfer. And wix-fetch also uses double quotes for identifiers, which makes sense, since you would be calling a service using JSON.
In short: when is something (in docs) JSON and when is it a JS Object?
Could somebody shed some light onto this?
P.S: And is it just me, or is ALL example code in doc about wix-pay gone, except startPayment? Maybe rewriting, because of @Quentin Plomteux ´s message this week?