I am pulling a JSON formatted string from a database in some cases this string is just an array, but it badly formatted. I have no control over the data shape.
The string looks like this:
"[Hello, World]"
I want to parse this string to an array using JSON.parse, but that doesn't work when there are no quotes arround it.
So I need to somehow transform this string to this ["Hello", "World"]
Related
How can I represent format of 2018-01-01T17:11:11.111+06:00 in string?
I've tried yyyy-MM-dd'T'HH:mm:ss.SSS+HH:mm, but it didn't work.
It is needed for range query in elasticsearch using elastic4s.
Let' try:
YYYY-MM-dd'T'HH:mm:ss.SSSz
I suggest to you this app for check the format:
https://esddd.herokuapp.com/
I have a time string, which looks like this: 20170822T194135+00. This is called basic ISO:8601 format, if I understood correctly.
When I try to parse it using ZonedDateTime, it throws exception, complaining that it can't parse it.
SO, how do I convert this string to a valid Joda datetime object?
Do I need to build manual "format" to parse it (this would be silly, considering it's a standard format)?
Desperately, I've actually tried to implement custom format:
const time = ZonedDateTime.parse(timeString, DateTimeFormatter.ofPattern(`yyyyMMdd'T'HHmmssZ`));
But, it throws error on column 15. Looks like it fails to parse the timezone. Is my implementation correct? How do I make it work?
I could do it using the pattern x as described in the docs (this pattern accepts offsets like +00).
Then I parsed directly to a ZonedDateTime:
const formatter = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmssx");
const time = ZonedDateTime.parse("20170822T194135+00", formatter);
The resulting time variable has the value equivalent to 2017-08-22T19:41:35Z.
The built-in formatters (such as ISO_LOCAL_DATE_TIME) can't parse this format, so the only way seems to be creating a formatter.
I am just started mongodb and facing issue when saving XML in string field. it add '\u0000' with each character in xml file. like
"\u0000?\u0000x\u0000m\u0000l\u0000 \u0000v\u0000e\u0000r\u0000s\u0000i\u0000o\u0000n
I need to save this XML as it is without JSON 0r BSON conversion in string field.
Till the time, I found a query to get xml back in correct format.
db.Test.find({"data":"XYZ"}).forEach(function(doc){
var xml = doc.data.replace(/\u0000/g,"");
print(xml);
})
I get json string from server. Then I parser it using SBJSON library. But when I show parse results in my label I have symbols like that
!
(normally it's !).
So how can I convert my json string to normal string?
Use this: https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString+HTML.m (specifically, the stringByDecodingHTMLEntities method).
From my XML file, I got a weird string (I think it's a blob data).
It looks like this:
0x244033242D212E430D21E2E3[.......]
It's a very very long string. My DB administrator told me that it comes from the database.
How to convert this string to a valid PDF file?
Thank you very much.
Regards,
Kael
A lot depends the database's manner of storing blob data, but if the format's not too exotic then the NSData and NSPropertyListSerialization classes should be able to convert it into something manageable.