fr0styy fr0styy - 1 year ago 136
JSON Question

Replace with unknown character

I am correcting a json-Array. I want to replace a few errors.

For Example: in

"index" : NumberInt(8),
i want to cut off
without the number where the * is, in order to make the json-file valid.

How can i do that? didn't find anything on google. it's quite hard to define this question.



"index" : NumberInt(8),

(Some way of changing the JSON)


"index" : 8,


after the marked answer i could figure out my specific case by myself.

I solved my provlem using the "Back-References" ($1, $2, etc)

Example, which i used for my case:

press cmd+R -> replace function

insert in Search-String:
insert in

what happens: it searches for "NumberInt()" and replaces it
with the , referenced by the $1-symbol.

Thanks for your help! i learned a lot

Answer Source

I think there might be a bit missing from the question but I'm going to make some assumptions and hope thats what you were going for.

I'm going to assume that NumberInt(8) is a string (if it's not you can operate on the object and pull out the first argument and set that as the value)

If we are looking to pull out what's in the parens we could use a basic Regexp (() around what we want as a second element):

v = "NumberInt(8)"
=> Array [ "NumberInt(8)", "8" ]

Should be able to parseInt() the second element and override the previous value.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download