Skip to content

Commit b5e9181

Browse files
author
github-actions
committed
v3.25.12.1
1 parent 8a72102 commit b5e9181

File tree

8 files changed

+67
-4
lines changed

8 files changed

+67
-4
lines changed

PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.4
22
Name: blpapi
3-
Version: 3.25.11.1
3+
Version: 3.25.12.1
44
Summary: Python SDK for Bloomberg BLPAPI
55
Home-page: http://www.bloomberglabs.com/api/
66
Author: Bloomberg L.P.

changelog.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
Version 3.25.12.1:
2+
==================
3+
- JSON serialization and deserialization support for elements
4+
Introduced `toJson()` and `fromJson(JSON)` methods to enable conversion
5+
between element objects and JSON.
6+
Requests can be constructed using `request.fromJson(REQUEST_JSON)`,
7+
events can be populated with `eventFormatter.fromJson(REQUEST_JSON)`,
8+
and messages can be converted to JSON using `message.toJson()`. You
9+
can also apply `toJson()` and `fromJson(JSON)` to any `Element` objects.
10+
11+
- Stability and performance improvements
12+
113
Version 3.25.11.1:
214
==================
315
- Stability and performance improvements

examples/demoapps/snippets/requestresponse/HistoricalDataRequest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def createRequest(service, options):
1616
# NOTE: this function uses `Request.__setitem__` to format a `Request`. See
1717
# the other `createRequest` functions in this `requestresponse` directory
1818
# for examples of alternative interfaces for formatting a `Request`.
19+
# An alternative using `request.fromJson` is shown in the comments below.
1920
request = service.createRequest("HistoricalDataRequest")
2021

2122
request[SECURITIES] = options.securities
@@ -28,6 +29,22 @@ def createRequest(service, options):
2829
request[MAX_DATA_POINTS] = 100
2930
request[RETURN_EIDS] = True
3031

32+
# Alternative: Using `Request.fromJson` to format the request
33+
# import json
34+
# REQUEST_JSON = f"""
35+
# {{
36+
# "securities": {json.dumps(options.securities)},
37+
# "fields": {json.dumps(options.fields)},
38+
# "periodicityAdjustment": "ACTUAL",
39+
# "periodicitySelection": "MONTHLY",
40+
# "startDate": "20200101",
41+
# "endDate": "20201231",
42+
# "maxDataPoints": 100,
43+
# "returnEids": true
44+
# }}
45+
# """
46+
# request.fromJson(REQUEST_JSON)
47+
3148
return request
3249

3350

@@ -36,6 +53,10 @@ def processResponseEvent(event):
3653
print(f"Received response to request {msg.getRequestId()}")
3754
print(msg)
3855

56+
# Alternative: Using `Message.toJson` to convert the message to JSON
57+
# jsonStr = msg.toJson()
58+
# print(jsonStr)
59+
3960

4061
__copyright__ = """
4162
Copyright 2021, Bloomberg Finance L.P.

src/blpapi.egg-info/PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.4
22
Name: blpapi
3-
Version: 3.25.11.1
3+
Version: 3.25.12.1
44
Summary: Python SDK for Bloomberg BLPAPI
55
Home-page: http://www.bloomberglabs.com/api/
66
Author: Bloomberg L.P.

src/blpapi/eventformatter.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,17 @@ def appendElement(self) -> None:
459459
internals.blpapi_EventFormatter_appendElement(self.__handle)
460460
)
461461

462+
def fromJson(self, jsonString: str) -> None:
463+
"""Equivalent to :meth:`getElement().fromJson(jsonString)
464+
<Element.fromJson>`.
465+
466+
Args:
467+
jsonString: JSON formatted string used to populate the current
468+
element.
469+
"""
470+
471+
self.getElement().fromJson(jsonString)
472+
462473
def fromPy(self, value: MappingType) -> None:
463474
r"""
464475
Format this :class:`EventFormatter`'s underlying :class:`Event` using

src/blpapi/message.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,15 @@ def asElement(self) -> Element:
384384
self.__element = weakref.ref(el)
385385
return el
386386

387+
def toJson(self) -> str:
388+
"""Equivalent to :meth:`asElement().toJson()<Element.toJson>`.
389+
390+
Returns:
391+
JSON string representation of this message.
392+
"""
393+
394+
return self.asElement().toJson()
395+
387396
def toString(self, level: int = 0, spacesPerLevel: int = 4) -> str:
388397
"""Format this :class:`Message` to the string at the specified
389398
indentation level.

src/blpapi/request.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ def fromPy(self, requestDict: Mapping) -> None:
115115
"""
116116
self.asElement().fromPy(requestDict)
117117

118+
def fromJson(self, jsonString: str) -> None:
119+
"""Equivalent to :meth:`asElement().fromJson(jsonString)
120+
<Element.fromJson>`.
121+
122+
Args:
123+
jsonString: JSON formatted string used to populate this request.
124+
"""
125+
126+
self.asElement().fromJson(jsonString)
127+
118128
def asElement(self) -> Element:
119129
"""
120130
Returns:

src/blpapi/version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
from . import internals
66

7-
__version__ = "3.25.11.1"
8-
__expected_cpp_sdk_version__ = "3.25.11"
7+
__version__ = "3.25.12.1"
8+
__expected_cpp_sdk_version__ = "3.25.12"
99

1010

1111
def print_version() -> None:

0 commit comments

Comments
 (0)