I get the bloomberg response like this. I would like to parse this and get the values out to be put in a excel or csv.
Bloomberg response is a headache in kind-of XML response. Is there a simple way to directly parse into JSON ? (from object 'session' or from object 'event')
HistoricalDataResponse = {
securityData = {
security = "S X5 Comdty"
eidData[] = {
14001, 14001
}
sequenceNumber = 1
fieldExceptions[] = {
}
fieldData[] = {
fieldData = {
date = 2015-05-06
PX_LAST = 956.0
OPEN = 967.25
}
fieldData = {
date = 2015-06-06
PX_LAST = 914.25
OPEN = 956.0
}
}
}
}
This is the response. Since we have "=" instead of ":" in any json online viewer it gives error as a invalid json.
The Bloomberg API does not produce valid JSON. Although you may get away with parsing it as JSON after making some modifications it is not a robust approach as the format may vary depending on the type of query and fields you want to retrieve (and may change in the future as it is not part of the specification).
You should parse it using the provided methods as detailed in the documentation (see the example in section 7.2.2 - Historical Data Request of the developer's guide).
Alternatively you could use jBloomberg (disclaimer: I'm the author) and your code would look like this:
More examples are available at the bottom of this page.