smartparens
smartparens copied to clipboard
Make rising sexps inside JSON literals work better
Think about the following cases:
- [ ] we might want to preserve the key and raise it one level up (DWIM?)
Depending on where the point is around address
we might keep or remove the child label.
{
method: 'POST',
uri: config.uriRoot + '/SendData/v1',
json: {
signDate: context.happenedAt,
address: {
zipCode: context.postalcode,
houseNumber: context.number,
}
},
}
If before address
, result should be replace parent
{
method: 'POST',
uri: config.uriRoot + '/SendData/v1',
address: {
zipCode: context.postalcode,
houseNumber: context.number,
},
}
(currently we get a line with json: address: { ...
)
If after address
result should be keep parent
{
method: 'POST',
uri: config.uriRoot + '/SendData/v1',
json: {
zipCode: context.postalcode,
houseNumber: context.number,
},
}
(this already works)
- [ ] If raising would bring us to top level we must always remove the key
example
{
method: 'POST',
uri: config.uriRoot + '/SendData/v1',
json: {
"SignDate": context.happenedAt,
"Name": context.name,
"ZipCode": context.postalcode,
"HouseNumber": context.number
}
}
We want to raise the json
field to top level, so we should only keep the body and get rid of label so the result is always
{
"SignDate": context.happenedAt,
"Name": context.name,
"ZipCode": context.postalcode,
"HouseNumber": context.number
}
- [ ] make sure
sp-splice-sexp-killing-around
preserves the value after the key, it makes no sense to raise just the key. - [ ] but make sure that if we're inside the value, the key is removed when doing
sp-splice-sexp-killing-around
- [ ] It would be cool if this could also work inside strings in other languages. Maybe we could do some tentative parsing of a string literal and if it seems like a json, use
json-read-from-string
and then DTRT.