json payload correct date format - json

I am trying to test a webserivce using postman by passing json payload, below is the payload for testing
{
"Shipments": [
{
"Reference1": "3002000411",
"Reference2": "3002000411",
"Reference3": null,
"Shipper": {
"Reference1": "3002000411",
"Reference2": null,
"AccountNumber": "60522818",
"PartyAddress": {
"Line1": "Makkah Al Mukarramh - Al Zaidy",
"Line2": "",
"Line3": "",
"City": "Makkah",
"StateOrProvinceCode": "",
"PostCode": "",
"CountryCode": "SA",
"Longitude": 39.72120670,
"Latitude": 21.38446500,
"BuildingNumber": "",
"BuildingName": "",
"Floor": "",
"Apartment": "",
"POBox": null,
"Description": ""
},
"Contact": {
"Department": "",
"PersonName": "ASQ Ecommerce Office",
"Title": "",
"CompanyName": "ASQ Ecommerce Office",
"PhoneNumber1": "0125371727",
"PhoneNumber1Ext": "",
"PhoneNumber2": "0125371727",
"PhoneNumber2Ext": "",
"FaxNumber": "",
"CellPhone": "0125371727",
"EmailAddress": "asmajani#asalqurashi.com",
"Type": ""
}
},
"Consignee": {
"Reference1": "3002000411",
"Reference2": null,
"AccountNumber": "",
"PartyAddress": {
"Line1": ", ضمد",
"Line2": "",
"Line3": "",
"City": "Damad",
"StateOrProvinceCode": "",
"PostCode": "",
"CountryCode": "SA",
"Longitude": 42.80390549,
"Latitude": 17.09896088,
"BuildingNumber": "",
"BuildingName": "",
"Floor": "",
"Apartment": "",
"POBox": null,
"Description": ""
},
"Contact": {
"Department": "",
"PersonName": "سامي ",
"Title": "",
"CompanyName": "سامي ",
"PhoneNumber1": "966501280041",
"PhoneNumber1Ext": "",
"PhoneNumber2": "966501280041",
"PhoneNumber2Ext": "",
"FaxNumber": "",
"CellPhone": "966501280041",
"EmailAddress": "loli201842#gmail.com",
"Type": ""
}
},
"ThirdParty": {
"Reference1": "",
"Reference2": "",
"AccountNumber": "60522818",
"PartyAddress": {
"Line1": "Makkah Al Mukarramh - Al Zaidy",
"Line2": "",
"Line3": "",
"City": "Makkah",
"StateOrProvinceCode": "",
"PostCode": "",
"CountryCode": "SA",
"Longitude": 39.72120670,
"Latitude": 21.38446500,
"BuildingNumber": "",
"BuildingName": "",
"Floor": "",
"Apartment": "",
"POBox": null,
"Description": ""
},
"Contact": {
"Department": "",
"PersonName": "ASQ Ecommerce Office",
"Title": "",
"CompanyName": "ASQ Ecommerce Office",
"PhoneNumber1": "0125371727",
"PhoneNumber1Ext": "",
"PhoneNumber2": "0125371727",
"PhoneNumber2Ext": "",
"FaxNumber": "",
"CellPhone": "0125371727",
"EmailAddress": "asmajani#asalqurashi.com",
"Type": ""
}
},
"ShippingDateTime": "2022-10-10T09:25:33.889+02:00",
"DueDate": "2022-10-10T09:25:33.889+02:00",
"Comments": null,
"PickupLocation": null,
"OperationsInstructions": null,
"AccountingInstrcutions": null,
"Details": {
"Dimensions": null,
"ActualWeight": {
"Unit": "KG",
"Value": 1.0
},
"ChargeableWeight": null,
"DescriptionOfGoods": "منتج خلطة وطن - 3مل - هدية (1) / منتج أسيل - 1/2 توله (2) / USPS (1) / COD (1)",
"GoodsOriginCountry": "SA",
"NumberOfPieces": 1,
"ProductGroup": "DOM",
"ProductType": "CDS",
"PaymentType": "3",
"PaymentOptions": "",
"CustomsValueAmount": null,
"CashOnDeliveryAmount": {
"CurrencyCode": "SAR",
"Value": 126.5
},
"InsuranceAmount": null,
"CashAdditionalAmount": null,
"CashAdditionalAmountDescription": null,
"CollectAmount": {
"CurrencyCode": "SAR",
"Value": 0.0
},
"Services": "CODS",
"Items": null,
"DeliveryInstructions": null,
"AdditionalProperties": null,
"ContainsDangerousGoods": false
},
"Attachments": null,
"ForeignHAWB": null,
"TransportType ": 0,
"PickupGUID": null,
"Number": null,
"ScheduledDelivery": null
}
],
"LabelInfo": {
"ReportID": 9729,
"ReportType": "URL"
},
"ClientInfo": {
"UserName": "user",
"Password": "pass",
"Version": "V1",
"AccountNumber": "123",
"AccountPin": "0000",
"AccountEntity": "JED",
"AccountCountryCode": "SA",
"Source": 24,
"PreferredLanguageCode": null
},
"Transaction": {
"Reference1": "",
"Reference2": "",
"Reference3": "",
"Reference4": "",
"Reference5": ""
}
}
while using post method i am facing below error
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Request Error</title>
<style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>
</head>
<body>
<div id="content">
<p class="heading1">Request Error</p>
<p xmlns="">The server encountered an error processing the request. Please see the <a rel="help-page" href="https://ws.aramex.net/ShippingAPI.V2/Shipping/Service_1_0.svc/Json/help">service help page</a> for constructing valid requests to the service. The exception message is 'The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://ws.aramex.net/ShippingAPI/v1/:Shipments. The InnerException message was 'There was an error deserializing the object of type System.Collections.Generic.List`1[[Corp.ShippingAPI.FrontEnd.Contracts.Shipment, Corp.ShippingAPI.FrontEnd.Contracts, Version=1.287.0.0, Culture=neutral, PublicKeyToken=null]]. DateTime content '2022-10-10T09:25:33.889+02:00' does not start with '\/Date(' and end with ')\/' as required for JSON.'. Please see InnerException for more details.'. See server logs for more details. The exception stack trace is: </p>
<p> at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part)
at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, PartInfo returnInfo, Object& returnValue)
at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeBodyCore(XmlDictionaryReader reader, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</p>
</div>
</body>
</html>

Related

How to achieve a toggle effect to individual ion-card?

Current issue : Whenever I am changing toggle, change-effect applying on every ion card.
Expected : I want to achieve a toggle effect individually on ion-card.
HTML :
<ion-grid>
<ion-row>
<ion-col *ngFor="let device of individual_room.devices">
<ion-card>
<ion-col><img src="assets/icon/favicon.png"/></ion-col>
<ion-card-content>
<ion-card-title>
{{ device.name }} <ion-badge item-end>{{ device.company }} </ion-badge>
</ion-card-title>
<ion-toggle [(ngModel)]="deviceStatus" (ionChange)="deviceStatusChange()"></ion-toggle>
</ion-card-content>
</ion-card>
</ion-col>
</ion-row>
</ion-grid>
CSS :
ion-card {
--background:#262626;
height: 150px;
width: 80% !important;
}
ion-toggle[aria-checked="false"]{
position: relative;
width: 60px;
&::before {
position: absolute;
content: "";
font-size: 10px;
line-height: 10px;
}
&::after {
position: absolute;
content: "";
}
}
ion-toggle[aria-checked="true"]{
position: relative;
width: 60px;
&::before {
position: absolute;
content: "";
}
&::after {
position: absolute;
content: "";
font-size: 10px;
line-height: 10px;
top: 0;
left: 3px;
color: #fff;
}
}
TS file :
const TOKEN_KEY = 'CapacitorStorage.user-token'
#Component({
selector: 'app-tabhome',
templateUrl: './tabhome.page.html',
styleUrls: ['./tabhome.page.scss'],
})
export class TabhomePage implements OnInit, AfterViewInit {
public deviceStatus:boolean = true;
ngOnInit() {
// locally provided json file
fetch('./assets/data/tabHomeData.json').then(res => res.json())
.then(res => {
this.data = res
});
const headerHeight = isPlatform('ios') ? 44 : 56
this.document.documentElement.style.setProperty(
'--header-position',
`calc(env(safe-area-inset-top) + ${headerHeight}px)`
)
}
deviceStatusChange(){
console.log("device toggle switch : "+this.deviceStatus);
}
ngAfterViewInit() {
this.lists.changes.subscribe((_) => {
this.listElements = this.lists.toArray()
})
}
tabHomeData.json :
{
"user": "Ram",
"rooms": [
{
"name": "LIVING ROOM",
"devices": [
{
"name": "fan",
"type": "FAN",
"company": "Philips",
"state": "ON",
"speed": 100
},
{
"name": "bulb",
"type": "BULB",
"company": "Philips",
"state": "ON",
"colour": "WHITE"
},
{
"name": "Hall TV",
"type": "TV",
"company": "Redmi",
"state": "OFF"
},
{
"name": "AC",
"type": "AC",
"company": "Philips",
"state": "ON",
"colour": "WHITE"
},
{
"name": "bulb",
"type": "BULB",
"company": "Philips",
"state": "ON",
"colour": "WHITE"
},
{
"name": "bulb",
"type": "BULB",
"company": "Philips",
"state": "ON",
"colour": "WHITE"
}
]
},
{
"name": "Kitchen",
"devices": [
{
"name": "fan",
"type": "FAN",
"company": "Philips",
"state": "OFF",
"speed": 50
},
{
"name": "bulb",
"type": "BULB",
"company": "Philips",
"state": "OFF",
"colour": "YELLOW"
}
]
},
{
"name": "BED ROOM",
"devices": [
{
"name": "fan",
"type": "FAN",
"company": "Philips",
"state": "OFF",
"speed": 50
}
]
},
{
"name": "WASH ROOM",
"devices": [
{
"name": "exast",
"type": "FAN",
"company": "Philips",
"state": "OFF"
},
{
"name": "bulb",
"type": "BULB",
"company": "Philips",
"state": "OFF",
"colour": "YELLOW"
},
{
"name": "bulb",
"type": "BULB",
"company": "Philips",
"state": "ON",
"colour": "WHITE"
}
]
}
]
}
In HTML file through json file in a loop , I am trying to set every device in a cardView. And want to use toggle for each card separately.
Please find below attached screenshot :
There are many different ways to achieve the toggle on the ion-card, below is one way to achieve it:
use the state property on your json to manage the toggle state of the toggle component on the card
modify your toggle component like so:
<ion-toggle (click)="deviceStatusChange(device)"
[checked]="device.state =='ON'">
Add toggle state change to the deviceStatusChangeMethod
public deviceStatusChange(device:any) {
device.state = (device.state === 'ON') ? 'OFF' : 'ON';
}

GEN_SIZE_INVALID, details: The object size passed is too big for processing

What does the following HttpResponse-Content actually mean when using autodesk-forge's webservice to copy a file-version via the resource "data/v1/projects/{PROJECT_ID}/versions?copyFrom={ESCAPED_VERSION_ID}"?
{"jsonapi":{"version":"1.0"},
"errors":[{
"id":"3a6cb28b-6656-451c-acfb-1c68ddb24a45",
"status":"400",
"code":"ERR_BAD_INPUT",
"title":"The request has invalid header or body",
"detail":"GEN_SIZE_INVALID, details: The object size passed is too big for processing."
}]}
Is there a limit to the number of versions that can be referenced or anything like that?
Here's the payload with dummy values:
{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "versions",
"relationships": {
"refs": {
"data": [
{
"type": "versions",
"id": "{{VersionURNforLink1}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink2}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink3}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink4}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink5}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink6}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink7}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink8}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink9}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink10}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink11}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink12}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink13}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink14}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink15}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink16}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink17}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink18}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink19}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink20}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink21}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink22}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink23}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
},
{
"type": "versions",
"id": "{{VersionURNforLink24}}",
"meta": {
"refType": "xrefs",
"direction": "from",
"extension": {
"type": "xrefs:autodesk.core:Xref",
"version": "1.1",
"data": {
"nestedType": "overlay"
}
}
}
}
]
}
}
}
}
From all the data we've been able to gather so far: There is in fact a limit on how many files can be referenced directly, which seems to be 50.
The reason it occurred in so many places for us when we didn't have any files referencing nearly that amount of other plans, was how the "CopyFrom"-functionality works.
Example on how to reproduce the problem:
Given "plan A" and "plan B" ("B" referencing "A"), upload both files and create their initial items/versions. Now do the following:
1.) re-upload "A" and create a new version.
2.) use "CopyFrom" on the latest version of "B" and define the reference to the latest version of "A".
Since "CopyFrom" adds references instead of replacing them, version #2 of "B" now holds two references. One towards the initial version #1 of "A" and one to the latest version of "A".
Repeat these steps enough times and you'll eventually run into this issue.
Solution:
Even though nothing except one reference has changed on "B", one needs to reupload the file defining all required references so version #N of "B" only references version #N of "A". (Be wary that this behaviour of course may change in the future!)

How to simplify multiple JSON-Schema switch-like statements

There is an example of a switch-like condition in the JSON Schema documentation.
https://json-schema.org/understanding-json-schema/reference/conditionals.html
I have added two more countries to the example, which both should have the same postal code patterns as Netherlands. I can get this example to work with two additional if/then structures, but it becomes messy when more items are to be added.
Is there DRYer version, e.g. like the hypothetical one below?
"properties": { "country": { "const": ["Netherlands", "Upperlands", "Lowerlands" } }
{
"type": "object",
"properties": {
"street_address": {
"type": "string"
},
"country": {
"enum": ["United States of America", "Canada", "Netherlands",
"Upperlands","Lowerlands"]
}
},
"allOf": [
{
"if": {
"properties": { "country": { "const": "United States of America" } }
},
"then": {
"properties": { "postal_code": { "pattern": "[0-9]{5}(-[0-9]{4})?" } }
}
},
{
"if": {
"properties": { "country": { "const": "Canada" } }
},
"then": {
"properties": { "postal_code": { "pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]" } }
}
},
{
"if": {
"properties": { "country": { "const": "Netherlands" } }
},
"then": {
"properties": { "postal_code": { "pattern": "[0-9]{4} [A-Z]{2}" } }
}
}
]
}
You could use the enum pattern instead. It's less verbose and easier to read, but the error messages you get are terrible, so I suggest you stick with the if/then pattern. Here's what using the enum pattern would look like.
{
"type": "object",
"properties": {
"street_address": {
"type": "string"
},
"country": {
"enum": ["United States of America", "Canada", "Netherlands",
"Upperlands","Lowerlands"]
}
},
"anyOf": [
{
"properties": {
"country": { "const": "United States of America" },
"postal_code": { "pattern": "[0-9]{5}(-[0-9]{4})?" }
}
},
{
"properties": {
"country": { "const": "Canada" },
"postal_code": { "pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]" }
}
},
{
"properties": {
"country": { "const": "Netherlands" },
"postal_code": { "pattern": "[0-9]{4} [A-Z]{2}" }
}
}
]
}
Although there isn't good way around the verbosity, there is something you can do to improve readability/maintainability. You can use definitions to hide the verbose parts.
{
"type": "object",
"properties": {
"street_address": {
"type": "string"
},
"country": {
"enum": ["United States of America", "Canada", "Netherlands",
"Upperlands","Lowerlands"]
}
},
"allOf": [
{ "$ref": "#/definitions/validate-us-postal-code" },
{ "$ref": "#/definitions/validate-ca-postal-code" },
{ "$ref": "#/definitions/validate-nl-postal-code" }
]
"definitions": {
"validate-us-postal-code": {
"if": {
"properties": { "country": { "const": "United States of America" } }
},
"then": {
"properties": { "postal_code": { "pattern": "[0-9]{5}(-[0-9]{4})?" } }
}
},
"validate-ca-postal-code": {
"if": {
"properties": { "country": { "const": "Canada" } }
},
"then": {
"properties": { "postal_code": { "pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]" } }
}
},
"validate-nl-postal-code": {
"if": {
"properties": { "country": { "const": "Netherlands" } }
},
"then": {
"properties": { "postal_code": { "pattern": "[0-9]{4} [A-Z]{2}" } }
}
}
}
}
This allows someone to be able to understand everything this schema does just by reading the first few lines. The verbose/complicated stuff is pushed to the bottom where you don't have to deal with it if you don't need to.

ElasticSearch - Match all nested variations in a document

I have several products with variations like the one below
{
"title": "100% Cotton Unstitched Suit For Men",
"slug": "100-cotton-unstitched-suit-for-men",
"price": 200,
"sale_price": 0,
"vendor_id": 32,
"featured": 0,
"viewed": 20,
"stock": 4,
"sku": "XXX-B",
"rating": 0,
"active": 1,
"vendor_name": "vendor_name",
"category": [
"men_fashion",
"traditional_clothing",
"unstitched_fabric"
],
"image": "imagename.jpg",
"variations": [
{
"variation_id": "34",
"stock": 5,
"price": 200,
"variation_image": "",
"sku": "XXX-C",
"size": "m",
"color": "red"
},
{
"variation_id": "35",
"stock": 5,
"price": 200,
"variation_image": "",
"sku": "XXX-D",
"size": "l",
"color": "red"
}
]
}
I am looking for a query that would have all of the below parameters
Get all products in a certain category
Get all products that are black
Get sizes l and m
My current Query:
{
"size": 15,
"from": 0,
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"match": {
"category": "women_fashion"
}
},
{
"nested": {
"path": "variations",
"query": {
"bool": {
"must": [{
"match": {
"variations.color": "red"
}
},
{
"match": {
"variations.size": "l"
}
},
{
"match": {
"variations.size": "m"
}
}
]
}
}
}
}
]
}
}
}
}
}
It works fine if i only search for 1 size. But once i search for 2 sizes it gives no records. My guess is that it looks for all 3 parameters in every nested variation, which obviously it cant find. How would i modify the query to search for
size: m, color: black
size: l, color: black
I have also tried using a nested filter, but the issue with this is that it works like "SHOULD" query while i am looking for a "MUST" query. ie. it shows all the products have large variations while i just want to show products that are large and red.
My Second Query:
{
"size": 15,
"from": 0,
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"match": {
"category": "women_fashion"
}
},
{
"nested": {
"path": "variations",
"query": {
"bool":{
"filter": [
{
"term": {
"variations.color": "red"
}
},
{
"term": {
"variations.size": "l"
}
}
]
}
}
}
}
]
}
}
}
}
}
You can put the size variations into a clause of it's own so at least one of the sizes will match
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"match": {
"category": "women_fashion"
}
},
{
"nested": {
"path": "variations",
"query": {
"bool": {
"must": [
{
"match": {
"variations.color": "red"
}
},
{
"query": {
"bool": {
"should": [
{
"match": {
"variations.size": "l"
}
},
{
"match": {
"variations.size": "m"
}
}
]
}
}
}
]
}
}
}
}
]
}
}
}
}
}

Make topbar and header float

I have a theme where I can select to make the header float when scrolling down a page or the topbar float.
I want to make them both float, can you please tell me what to change?
Here is the code from the settings_schema.json file:
{
"type": "header",
"content": "Header Style"
},
{
"type": "select",
"id": "theme_float_style",
"label": "Float style",
"options": [
{
"value": "",
"label": "Default"
},
{
"value": "keep-topbar",
"label": "Float Topbar"
},
{
"value": "keep-header",
"label": "Float Header"
}
],
"default": ""
},
when you select the header to float, this is what appears in settings_data.json:
"theme_float_style": "keep-header",
css:
/* ---Header--- */
body{
&.keep-header{
.mini-bar{
#include box-shadow(0px 2px 3px 0px rgba(0,0,0,0.2));
#header_logo{
padding:5px 0;
img{
width:449px;
}
}
}
}
}
body{
&.keep-topbar{
}