3
I’m using Scala and I have an http response like this:
_SS_MainSolrCallbackH(
{
response: {
numFound: 1,
start: 0,
maxScore: 4.9338827,
docs: [
{
tipo: "M",
id: "mus1933196",a
s: 4.9338827,
u: "daniellaalcarpe",
d: "lagrima-de-amor",
dd: "",
f: "202114_20130510215437.jpg",
a: "Daniella Alcarpe",
t: "Lágrima De Amor",
g: "MPB"
}
]
},
highlighting: {
mus1933196: {
titulo: [
"Lágrima <b>De</b> <b>Amor</b>"
]
}
}
}
)
If I try to parse this string as json, it will fail because it is not exactly a json. What is the best way to remove the part _SS_MainSolrCallbackH( )
of the string, leaving only the json hash?
Hello, Daniel. Is this part you want to remove always the same or similar? Have you ever thought about just using
substring
?– utluiz
actually it’s always the same, but I wanted to do it in a generic way. I solved it temporarily with string.replace("_Ss_mainsolrcallbackh(", ""). take(string.size - 2) but it looks kind of ugly...
– Daniel Cukier