1

I am trying to split the following standard: This is column B

{"Dom":"DSQR","ID":"987","Name":"Stephen Jones"}
{"Dom":"DSQR","ID":"987","Name":"Tania Dewes"}

The formula is as follows:

=ArrayFormula(IF(B2:B="", "", TRIM(SPLIT(B2:B,M2)))) 

M2 cell is:

ID":" 

Result is:
enter image description here

Could you explain why Stephen Jones shows correctly and Tania doesn't? I'd like the split to work like it does on the first line.

1

2 Answers 2

1

That's because there's none of ID":" in Stephen Jones, while there's a D in Tania Dewes. Suggest using a proper parser, like a custom function to parse JSON.

Sign up to request clarification or add additional context in comments.

Comments

0

use:

=INDEX(IFERROR(REGEXREPLACE(SPLIT(A1:A, ":,", 1), "[\{\}""]", )))

enter image description here

or:

=INDEX(IFERROR(SPLIT(REGEXREPLACE(A1:A, "[\{\}""]|ID", ), ":,", 1)))

enter image description here

2 Comments

@Jerome answer updated
While it works here, I don't think json can or should be parsed like this. Plenty of things could go wrong. Just for eg, If Name is Tania, Dewes, it'll fail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.