javascriptc#.netjsondata-mapping

How to link JSON keys to eachother?


I'm trying to think of a solution how to link 2 different json formats and keys to eachother, for example the following 2 formats:

{
   "price": [
   511,
   499,
   419,
   312
   ],
   "paid": "OK",
   "contract": "year",
   "begindate": "01/01/2018",
   "enddate": "01/01/2019"
}

And

{
   "payments": "OK",
   "contract period": "year",
   "start": "01/01/2018",
   "stop": "01/01/2019",
   "pricing": [
     511,
     499,
     419,
     312
   ]
}

In this case I'm trying to link price to pricing, paid to payments, contract to contract period, etc. I'm trying to find a way to create a web application for this myself instead to hardcode it.

Thanks in advance!


Solution

  • You could take an object with the relation of the keys.

    relation = {
        price :'pricing',
        paid: 'payments',
        contract: 'contract period',
        begindate: 'start',
        enddate: 'stop'
    };