R
Reactiflux

help-js

✅ – shuntera12 – 23-03 Nov 9

Sshuntera1211/9/2022
Hey everyone! How to add a property to object after a particular property? Like if const obj = { a:"Name", b:"Rohit", age:12, } and i want to add the property after b, can anyone help me with this? so in my case there are thousand objects with different structure but same property names, and I want to add a new property after a particular property, how will I do so?
SS3BAS11/9/2022
You should not use an object if you want a specific order You should use an array instead What's the use case here? @shuntera12
Sshuntera1211/9/2022
I am using Prismic (CMS) and I want to change the data of the CMS, since there is no write API, I would need to manually upload JSON files to the CMS. Now, the CMS will only work if the imported json file is in correct order/structure. Therfore, i want to add new properties in json file at the correct order @S3BAS
SS3BAS11/9/2022
Now, the CMS will only work if the imported json file is in correct order
Are you really, really sure about this? I highly doubt that's a requirement
Sshuntera1211/9/2022
Lemme checkkk There's nothing mentioned in the docs about the structure, but my senior told me that the structure should remain the same @S3BAS what should I do now? 😓
SS3BAS11/9/2022
The structure in terms of keys/values being present sure But the order should not matter
Sshuntera1211/9/2022
so can I proceed with adding properties at random order, right?
SS3BAS11/9/2022
Have you tried it out? :p (but yes, very likely)
Sshuntera1211/9/2022
I don't have access to upload, only thing I can provide my manager is my json file
SS3BAS11/9/2022
Ah, but yeah the order of the keys in the object should not matter
Sshuntera1211/9/2022
yep, thanks for clarifying 💯
SS3BAS11/9/2022
meowthumbsup
UUUnknown User11/10/2022
3 Messages Not Public
Sign In & Join Server To View

Looking for more? Join the community!