Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4220

Allow Service calls to be made using TSimpleJSONProtocol (using Simple JSON)

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Wish List
    • None

    Description

      https://github.com/degupta/human_readable_json_protocol

      If we publish our Services/APIs as Thrift today you can't make requests using simple Human Readable JSON. This means publishing our APIs to third party users means they have to

      1. Know how to use Thrift
      2. Have all the Thrift definition files or the generated code

      Or we have to build Libraries for each of the platforms we want to support.

      This is not always possible.

      I propose we do something like this:

      exception SystemException {
        1: i32 errorCode,
        2: string message,
      }
      
      struct User {
        1: string id,
        2: string email,
        3: string name,
        4: i64 validatedAt
      }
      
      struct LoginResult {
        1: string authToken,
        2: User currentUser
      }
      
      service AuthenticationService {
        LoginResult login(1: string email, 2: string password) throws(1: SystemException err)
      }
      

      Request Format:

      {
        "method": "METHOD_NAME",
        "arguments": { ... }
      }
      
      {
        "method": "login",
        "arguments": {
          "email": "devansh@wi.co",
          "password": "password"
        }
      }
      

      RESULT:

      {
        "method": "login",
        "result": {
          "success": {
            "authToken": "some_auth_token",
            "currentUser": {
              "id": "6a6c982b-62f9-46d2-aff9-bd3a1cdf43f9",
              "email": "user1@wi.co",
              "name": "user1",
              "validatedAt": 0
            }
          }
        }
      }
      

      This uses the JSON generated by the JSON Generator as "metadata" to figure out the Field Keys and Types.

      Attachments

        Activity

          People

            Unassigned Unassigned
            devansh_gupta91 Devansh Gupta
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: