Json validation

[
{“data”: {“category”: “shotguns”, “upc”: “741566904462”, “name”: “European American Armory Churchill 812 Field 812 Field”, “model”: “Churchill 812 FIELD”, “gauge”: “20 Gauge”, “weight”: 110.4, “barrel_length”: 26.0, “overall_length”: 45.0, “capacity”: {“magazine”: 2}, “action”: “Break”, “finish”: “Blue”, “sight_type”: “Fiber Optic Front”, “safety_features”: “Top Tang”, “product_description”: “Just starting out in the shotgun sports or looking for a classic beauty with a hunting pedigree at an affordable price? You’ve found it in the Churchill® 812 Field over-and-under 12 ga. 3-inch shotgun. Perfectly balanced for an easy swing through shot at birds or clay targets. Built on standard checkered walnut stock and forend with a steel receiver, it features a vented rib with a fiber optic front sight, auto ejectors and auto safety.”, “raw_data”: “<table class="woocommerce-product-attributes shop_attributes"><tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_gsin"><th class="woocommerce-product-attributes-item__label">GSIN<td class="woocommerce-product-attributes-item__value">

EAACO-YWEW4NLS

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_parent-gsin"><th class="woocommerce-product-attributes-item__label">Parent GSIN<td class="woocommerce-product-attributes-item__value">

EAACO-BG3REDB8-P

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_manufacturer-name"><th class="woocommerce-product-attributes-item__label">Manufacturer Name<td class="woocommerce-product-attributes-item__value">

European American Armory / EAA Corp

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_model"><th class="woocommerce-product-attributes-item__label">Model<td class="woocommerce-product-attributes-item__value">

Churchill 812 FIELD

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_series"><th class="woocommerce-product-attributes-item__label">Series<td class="woocommerce-product-attributes-item__value">

812 Field

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_upc"><th class="woocommerce-product-attributes-item__label">UPC<td class="woocommerce-product-attributes-item__value">

741566904462

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_manufacturer-part-number"><th class="woocommerce-product-attributes-item__label">Manufacturer Part Number<td class="woocommerce-product-attributes-item__value">

111322

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_msrp"><th class="woocommerce-product-attributes-item__label">MSRP<td class="woocommerce-product-attributes-item__value">

1286

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_brand"><th class="woocommerce-product-attributes-item__label">Brand<td class="woocommerce-product-attributes-item__value">

European American Armory

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_category-level-2"><th class="woocommerce-product-attributes-item__label">Category Level 2<td class="woocommerce-product-attributes-item__value">

<a href="https://www.gungenius.com/category-level-2/shotguns/\” rel="tag">Shotguns

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_category-level-3"><th class="woocommerce-product-attributes-item__label">Category Level 3<td class="woocommerce-product-attributes-item__value">

<a href="https://www.gungenius.com/category-level-3/over-under-shotguns/\" rel="tag">Over Under Shotguns

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_action"><th class="woocommerce-product-attributes-item__label">Action<td class="woocommerce-product-attributes-item__value">

Break

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_barrel-length"><th class="woocommerce-product-attributes-item__label">Barrel Length<td class="woocommerce-product-attributes-item__value">

<a href="https://www.gungenius.com/barrel-length/26/\" rel="tag">26

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_capacity-standard"><th class="woocommerce-product-attributes-item__label">Capacity Standard<td class="woocommerce-product-attributes-item__value">

2

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_chamber-size"><th class="woocommerce-product-attributes-item__label">Chamber Size<td class="woocommerce-product-attributes-item__value">

3

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_frame-finish"><th class="woocommerce-product-attributes-item__label">Frame Finish<td class="woocommerce-product-attributes-item__value">

Blue

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_gauge"><th class="woocommerce-product-attributes-item__label">Gauge<td class="woocommerce-product-attributes-item__value">

20 Gauge

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_is-display-model"><th class="woocommerce-product-attributes-item__label">Is Display Model<td class="woocommerce-product-attributes-item__value">

<a href="https://www.gungenius.com/is-display-model/false/\" rel="tag">FALSE

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_safety"><th class="woocommerce-product-attributes-item__label">Safety<td class="woocommerce-product-attributes-item__value">

TRUE

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_safety-description"><th class="woocommerce-product-attributes-item__label">Safety Description<td class="woocommerce-product-attributes-item__value">

Top Tang

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_sights-general"><th class="woocommerce-product-attributes-item__label">Sights General<td class="woocommerce-product-attributes-item__value">

Fiber Optic Front

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_total-length"><th class="woocommerce-product-attributes-item__label">Total Length<td class="woocommerce-product-attributes-item__value">

45

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_weight-in-ounces"><th class="woocommerce-product-attributes-item__label">Weight In Ounces<td class="woocommerce-product-attributes-item__value">

110.4

<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item–attribute_pa_weight-in-pounds"><th class="woocommerce-product-attributes-item__label">Weight In Pounds<td class="woocommerce-product-attributes-item__value">

6

", “brand”: {“data”: {“name”: “European American Armory”}}, “images”: {“urls”: [“https://www.gungenius.com/wp-content/uploads/eaa-Churchill-812-Field-Over-Under-Shotguns-EAACO-YWEW4NLS.jpg”]}}},…]

I have like this json in an array I have few conditiontions that each key should satisfy I dont know how to do it I have set of rulles like
{
“data”: {
// one of [“handguns”, “rifles”, “shotguns”, “muzzleloaders”, “black_powder_firearms”]
“category”: “handguns”,
// just string with numbers
“upc”: “764503022347”,
// just string
“name”: “Glock 19”,
// just string
“model”: “19”,
// just string
“caliber”: “9mm”,
// number weight in oz
“weight”: 23.65,
// number in inch
“barrel_length”: 4.02,
// number in inch
“overall_length”: 7.28,
“capacity”: {
// required
“magazine”: 15,
”chamber”: 1
},
// just string
“action”: “Semi-Automatic”,
// just string
“material”: “Polymer”,
// just string
“finish”: “Black”,
// just string
“sight_type”: “Fixed”,
// just string
“safety_features”: “Safe Action”,
// just string
“product_description”: “The Glock 19 is a compact version of the Glock 17, featuring a shorter barrel and grip for better concealment and handling.”,
// just string
“color”: “red”,
// just string
“gauge”: “12 GA”,
// handguns frame size
“frame_size”: “compact”,
// just string
“stock_material”: “wood”,
// just string
“stock_type”: “adjustable”,
// integer count of included magazines
“magazines_included”: 8,
// A structured html table listing all technical details.
“raw_data”: “

UPC ECOM33874289
Action SIDE BY SIDE
Barrel Length 28 BARREL
Capacity 2 ROUNDS
Finish BLACK
Gauge 12 GA
Weight 6.4 LBS.
”,
“brand”: {
“data”: {
// just brand name
“name”: “Fively”
}
},
“state_compliance”: {
//A list of states where the rifle complies with local regulations.
“Alabama”: true,
“Alaska”: true,
“Georgia”: false
},
“images”: {
// deprecated now
“urls”: [
https://example.com/images/glock19-1.jpg”,
https://example.com/images/glock19-2.jpg
],
// Use it now
“ids”: [
1234,
567
],

    }
}

}
want to validate each JSON object in an array individually. If any JSON object is incorrect, it should log the incorrect JSON objects in an array. This ensures that each JSON object is validated one by one.

@SNEHA_RAJ_A,

Deserialize the JSON object to array or any suitable data type and then do the validation. Use Deserialize JSON activity.

Thanks,
Ashok :slight_smile:

I have tried it but how will I give my conditions



It should 1st loop and have the conditioned followed by it can u plz let me know the steps to to it

@SNEHA_RAJ_A,

Pass output variable of the activity Deserialize Json Array to For Each Item.

Also make sure correct Argument type is selected.

Thanks,
Ashok :slight_smile:

Assign: Object reference not set to an instance of an object.




item(“data”)(“category”).ToString

jsonObj(“data”).GetType().ToString.Equals(“Newtonsoft.Json.Linq.JObject”)
item(“data”)(“category”).ToString

in this its throwing an error

For which variable exactly you are getting this error? Also this error stats that, your variable is not initialized or is null.

Check for it.

Thanks,
Ashok :slight_smile:



item is I mentioned in item name

item(“data”)(“category”).ToString

@SNEHA_RAJ_A,

What’s datatype of Var? you will have to initialize it before you assign something to it.

Thanks,
Ashok :slight_smile: