Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

JSON file

Feras95p
8 - Asteroid

Dear all,

 

I have an input file which contain 3 variables information which are :-

 

1- Price

2- Barcode

3- Quantity

 

as shown in the picture below:

Varibles.PNG

 

 

I have a total of these three variables 82 rows. What I'm looking for is to create a workflow that take each  row and generate it in the JSON file as below, the red colored must be duplicated 82 times and changing the variables as per the variables file   :-

 

{
    "skin""weborder",
    "establishmentId"3,
    "items": [
        {
            "price": 48,
            "barcode": 100000005774,
            "quantity": 1
        },
        {
            "price": 60,
            "barcode": 100000005859,
            "quantity": 1
        }
    ],
    "orderInfo": {
        "dining_option"104,
        "asap":true,
        "customer": {
            "address": {
                "address""XX",
                "city""XX",
                "country""XX",
                "province""",
                "state""",
                "street_1""",
                "street_2""",
                "zipcode"""
            },
            "phone""0000000001",
            "first_name""XX",
            "last_name""Auto-poster",
            "email""XX"
        },
        "call_name""XX",
        "call_number"909090
    },
    "paymentInfo": {
        "amount""0.00",
        "type"203,
        "transaction_id""909090"
    }
}

 

 

Any help in that please?

 

I have attached the variables file.

 

 

 

9 REPLIES 9
PhilipMannering
16 - Nebula
16 - Nebula

Hi @Feras95p ,

 

Perhaps something like this... see attached.

Feras95p
8 - Asteroid

@PhilipMannering  Many thanks for helping! But I have a problen the sequence should be like that barcode, price, quantity and all small letter. Also the bracket [ after items should be removed and the code should be as shown below:

 

 


"items": [
{
"barcode": "100010001",
"price": 48,
"quantity": 107
},
{
"barcode": "100010002",
"price": 48,
"quantity": 124
},
{
"barcode": "100010003",
"price": 48,
"quantity": 58
},
{
"barcode": "100010004",
"price": 48,
"quantity": 82
},
{
"barcode": "100010005",
"price": 48,
"quantity": 89
},
{
"barcode": "100010006",
"price": 48,
"quantity": 124
},
{
"barcode": "100010007",
"price": 48,
"quantity": 70
},
{
"barcode": "100010008",
"price": 48,
"quantity": 77
},
{
"barcode": "100010009",
"price": 48,
"quantity": 140
},
{
"barcode": "100010010",
"price": 48,
"quantity": 119
},
{
"barcode": "100010011",
"price": 48,
"quantity": 45
},
{
"barcode": "100010012",
"price": 48,
"quantity": 71
},
{
"barcode": "100010013",
"price": 48,
"quantity": 175
},
{
"barcode": "100010014",
"price": 48,
"quantity": 112
},
{
"barcode": "100010015",
"price": 48,
"quantity": 41
},
{
"barcode": "100010016",
"price": 48,
"quantity": 57
},
{
"barcode": "100010017",
"price": 48,
"quantity": 101
},
{
"barcode": "100010018",
"price": 48,
"quantity": 119
},
{
"barcode": "100010019",
"price": 48,
"quantity": 76
},
{
"barcode": "100010020",
"price": 48,
"quantity": 67
},
{
"barcode": "100010021",
"price": 48,
"quantity": 132
},
{
"barcode": "100010022",
"price": 48,
"quantity": 68
},
{
"barcode": "100010023",
"price": 48,
"quantity": 53
},
{
"barcode": "100010024",
"price": 48,
"quantity": 75
},
{
"barcode": "100010025",
"price": 48,
"quantity": 50
},
{
"barcode": "100010026",
"price": 48,
"quantity": 126
},
{
"barcode": "100010027",
"price": 48,
"quantity": 52
},
{
"barcode": "100010028",
"price": 48,
"quantity": 87
},
{
"barcode": "100010029",
"price": 48,
"quantity": 110
},
{
"barcode": "100010030",
"price": 48,
"quantity": 60
},
{
"barcode": "100010031",
"price": 48,
"quantity": 53
},
{
"barcode": "100010032",
"price": 48,
"quantity": 86
},
{
"barcode": "100010033",
"price": 48,
"quantity": 140
},
{
"barcode": "100010034",
"price": 48,
"quantity": 78
},
{
"barcode": "100010035",
"price": 48,
"quantity": 59
},
{
"barcode": "100010036",
"price": 48,
"quantity": 28
},
{
"barcode": "100010037",
"price": 48,
"quantity": 72
},
{
"barcode": "100010038",
"price": 48,
"quantity": 94
},
{
"barcode": "100010039",
"price": 48,
"quantity": 44
},
{
"barcode": "100010040",
"price": 48,
"quantity": 55
},
{
"barcode": "100010041",
"price": 48,
"quantity": 231
}
],  

PhilipMannering
16 - Nebula
16 - Nebula

Hi @Feras95p 

 

I think this is more accurate (see attached). The only thing lacking possibly is the indentation. But it's should still be valid JSON. Let me know if it works.

Feras95p
8 - Asteroid

Hi @PhilipMannering ,

 

 

How are you? I have you're doing well.

 

I modified the json file only but it's not getting output with my I don't know why! Can you help me?

 

I modified the code only to this one:-

 

{
    "skin""weborder",
    "establishmentId"1,
    "items": [
        {
            "barcode""****",
            "price"**,
            "quantity"**
        }
    ],
    "orderInfo": {
        "dining_option"109,
        "asap"true,
        "customer": {
            "phone""0000011112",
            "first_name""",
            "last_name""Auto-poster",
            "email"""
        },
        "call_name""Paid-Orders",
        "call_number"909080
    },
    "paymentInfo": {
        "amount""0.00",
        "type"7,
        "transaction_id""909080"
    },
    "discounts": [
        {
            "barcode""MMD22",
            "amount"**
        }
    ]
}
 
PhilipMannering
16 - Nebula
16 - Nebula

Perhaps this works?

Feras95p
8 - Asteroid

Hi @PhilipMannering , 

 

Thanks for helping ! Unfortunately, it's not working ... Maybe because of the change in the JSON  file.

 

{
    "skin""weborder",
    "establishmentId"1,
    "items": [
        {
            "barcode""****",
            "price"**,
            "quantity"**
        }
    ],
    "orderInfo": {
        "dining_option"109,
        "asap"true,
        "customer": {
            "phone""0000011112",
            "first_name""",
            "last_name""Auto-poster",
            "email"""
        },
        "call_name""Paid-Orders",
        "call_number"909080
    },
    "paymentInfo": {
        "amount""0.00",
        "type"7,
        "transaction_id""909080"
    },
    "discounts": [
        {
            "barcode""MMD22",
            "amount"**
        }
    ]
}
 
PhilipMannering
16 - Nebula
16 - Nebula

What's not working? Can you share the exact output you expect? ... and then I'll just try and match that.

Feras95p
8 - Asteroid

Hi @PhilipMannering ,

 

This is the output:

{
"skin": "weborder",
"establishmentId": 1,
"items": [
{
"barcode": "****",
"price": **,
"quantity": **
}
],
"orderInfo": {
"dining_option": 109,
"asap": true,
"customer": {
"phone": "0000011112",
"first_name": "",
"last_name": "Auto-poster",
"email": ""
},
"call_name": "Paid-Orders",
"call_number": 909080
},
"paymentInfo": {
"amount": "0.00",
"type": 7,
"transaction_id": "909080"
},
"discounts": [
{
"barcode": "MMD22",
"amount": **
}
]
}

 

 

 

 

 

 

Luke_C
17 - Castor
17 - Castor

@Feras95p Is this any different than this thread? I posted a solution there that seems to be very similar to this https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Generate-rows-in-code/m-p/921523#M2251...

 

Labels