Pages

9/10/18

Using Python 3.7 dataclasses in JSON (de)serialization purposes

python json dataclasses
    One of the most common process that goes together with APIs creation is a serialization (marshalling) or deserialization (unmarshalling) of data. So, what is (de)serialization? According to Wikipedia it is the process of translating data structures or object state into a format that can be stored (for example, in a file or memory buffer) or transmitted (for example, across a network connection) and reconstructed later (possibly in a different computer environment). You may ask "Hey, python has already tons of different packages for these purposes". And this is true. There are many cool packages like marshmallow, but in this article we'll be talking about (de)serialization with Python 3.7 standard features.

12/11/15

Integrating WordPress and Yii2

In this article, we are going to integrate Yii2 and WordPress applications. It can be useful in case when the WordPress app is a client and the Yii2 app is an API provider. Yes, you can say it can be done with WordPress natively without using of Yii2, but Yii2 Framework has a lot of built-in instruments that helps to create an API ASAP. ОК. Let's start.

12/6/15

Getting selected fields from the relation in Yii2

During building the REST API sometimes, we need to get related objects with the main object(s).

The main benefit of this approach is getting of all needed data at one query. Just agree it's cool! Let's try to implement this feature in Yii2.

By default, Yii2 has an implementation to get the related objects, but it fetches the whole record which can be too complex. And when you need to get for example only the user's name or some other attribute you will get all fields.