Convert the enrollment request to a JSON object
516861
private JsonObject toJsonObject() {
        JsonObjectBuilder factory = Json.createObjectBuilder();
        if (profile != null) {
            factory.add("profile", profile);
        }
        if (!hosts.isEmpty()) {
            JsonArrayBuilder ab = Json.createArrayBuilder();
            for (String host : hosts) {
                ab.add(host);
            }
            factory.add("hosts", ab.build());
        }
        if (label != null) {
            factory.add("label", label);
        }

        if (caName != null) {
            factory.add(HFCAClient.FABRIC_CA_REQPROP, caName);
        }
        factory.add("certificate_request", csr);

        if (attrreqs != null) {
            JsonArrayBuilder ab = Json.createArrayBuilder();
            for (AttrReq attrReq : attrreqs.values()) {
                JsonObjectBuilder i = Json.createObjectBuilder();
                i.add("name", attrReq.name);
                if (attrReq.optional != null) {
                    i.add("optional", attrReq.optional);
                }
                ab.add(i);

            }
            factory.add("attr_reqs", ab.build());
        }

        return factory.build();
    }
867970
def from_json(cls, json):
        """"""
        obj = cls(name=json['name'],
                  code=json['code'],
                  numeric_code=json['numeric_code'],
                  symbol=json['symbol'],
                  exponent=json['exponent'],
                  entities=json['entities'],
                  withdrawal_date=json['withdrawal_date'],
                  subunits=json['subunits'])
        return obj
1062382
def to_json
      attributes = {
        "summary" => title,
        "visibility" => visibility,
        "transparency" => transparency,
        "description" => description,
        "location" => location,
        "start" => time_or_all_day(start_time),
        "end" => time_or_all_day(end_time),
        "reminders" => reminders_attributes,
        "guestsCanInviteOthers" => guests_can_invite_others,
        "guestsCanSeeOtherGuests" => guests_can_see_other_guests
      }

      if id
        attributes["id"] = id
      end

      if timezone_needed?
        attributes['start'].merge!(local_timezone_attributes)
        attributes['end'].merge!(local_timezone_attributes)
      end

      attributes.merge!(recurrence_attributes)
      attributes.merge!(color_attributes)
      attributes.merge!(attendees_attributes)
      attributes.merge!(extended_properties_attributes)

      JSON.generate attributes
    end
60172
def to_json(self):
        

        result = super(Locale, self).to_json()
        result.update({
            'code': self.code,
            'name': self.name,
            'fallbackCode': self.fallback_code,
            'optional': self.optional,
            'contentDeliveryApi': self.content_delivery_api,
            'contentManagementApi': self.content_management_api
        })
        return result
1064573
def to_json(self, is_admin=False):
        
        if is_admin:
            return {
                'accountId': self.account_id,
                'accountName': self.account_name,
                'accountType': self.account_type,
                'contacts': self.contacts,
                'enabled': True if self.enabled == 1 else False,
                'requiredRoles': self.required_roles,
                'properties': {to_camelcase(prop.name): prop.value for prop in self.account.properties}
            }
        else:
            return {
                'accountId': self.account_id,
                'accountName': self.account_name,
                'contacts': self.contacts
            }
493413
def to_JSON(self):
        
        return json.dumps({"reception_time": self._reception_time,
                           "Location": json.loads(self._location.to_JSON()),
                           "Weather": json.loads(self._weather.to_JSON())
                           })
632246
def json_requested():
    """"""
    best = request.accept_mimetypes.best_match(
        ['application/json', 'text/html'])
    return (best == 'application/json' and
            request.accept_mimetypes[best] >
            request.accept_mimetypes['text/html'])
494240
def to_json(*a)
      # Hack to override RightScale namespace with Nanite for downward compatibility
      class_name = self.class.name
      if class_name =~ /^RightScale::(.*)/
        class_name = "Nanite::" + Regexp.last_match(1)
      end

      js = {
        'json_class' => class_name,
        'data'       => instance_variables.inject({}) do |m, ivar|
                          name = ivar.to_s.sub(/@/, '')
                          m[name] = instance_variable_get(ivar) unless NOT_SERIALIZED.include?(name)
                          m
                        end
      }.to_json(*a)
      @size = js.size
      js = js.chop + ",\"size\":#{@size}}"
    end
463343
def get_student_enrollments(self):
        
        # the request is done in behalf of the current logged in user
        resp = self.requester.get(
            urljoin(self.base_url, self.enrollment_url))
        resp.raise_for_status()
        return Enrollments(resp.json())
967649
def ToJson(self):
        
        json = super(AccountState, self).ToJson()
        addr = Crypto.ToAddress(self.ScriptHash)

        json['address'] = addr
        json['script_hash'] = str(self.ScriptHash)
        json['frozen'] = self.IsFrozen
        json['votes'] = [v.hex() for v in self.Votes]

        balances = []
        for key, value in self.Balances.items():
            balances.append({'asset': key.To0xString(), 'value': value.ToString()})

        json['balances'] = balances
        return json
1027803
def _json_to_sectionstatus(section_data):
    
    section_status = SectionStatus()
    if section_data["AddCodeRequired"] == 'true':
        section_status.add_code_required = True
    else:
        section_status.add_code_required = False
    section_status.current_enrollment = int(section_data["CurrentEnrollment"])
    current_period = int(section_data["CurrentRegistrationPeriod"])
    section_status.current_registration_period = current_period
    if section_data["FacultyCodeRequired"] == 'true':
        section_status.faculty_code_required = True
    else:
        section_status.faculty_code_required = False

    limit_estimate = int(section_data["LimitEstimateEnrollment"])
    section_status.limit_estimated_enrollment = limit_estimate

    indicator = section_data["LimitEstimateEnrollmentIndicator"]
    section_status.limit_estimate_enrollment_indicator = indicator
    section_status.room_capacity = int(section_data["RoomCapacity"])
    section_status.sln = int(section_data["SLN"])
    section_status.space_available = int(section_data["SpaceAvailable"])
    if section_data["Status"] == "open":
        section_status.is_open = True
    else:
        section_status.is_open = False

    return section_status
879149
def json(self):
        '''  '''
        ctype = self.environ.get('CONTENT_TYPE', '').lower().split(';')[0]
        if ctype == 'application/json':
            b = self._get_body_string()
            if not b:
                return None
            return json_loads(b)
        return None
1365820
def ToJson(self):
        
        json = super(ClaimTransaction, self).ToJson()

        json['claims'] = [claim.ToJson() for claim in self.Claims]

        return json
530976
def userToJson(user):
    
    obj = {
        'id': user.id,
        'username': user.username,
        'name': user.get_full_name(),
        'email': user.email,
    }

    return obj
463379
def client_json(options)
      {
        client: {
          username: options[:username],
          name: options[:name],
          email: options[:email],
          public_key: File.read(options[:public_key])
        }
      }.to_json
    end
781380
def to_json(self):
        
        return {
            'resourceType': self.resource.resource_type_id,
            'resourceId': self.id,
            'accountId': self.resource.account_id,
            'account': self.account,
            'location': self.resource.location,
            'properties': {to_camelcase(prop.name): prop.value for prop in self.resource.properties},
            'tags': [{'key': t.key, 'value': t.value} for t in self.resource.tags]
        }
1266906
def gen_def_json_scheme(self, req, method_fields=None):
        
        json_dict = dict(
            ApplicationId=req,
            RequestId=req,
            SessionId=req,
            Password=self.auth.password,
            Username=self.auth.username
        )
        if method_fields is not None:
            json_dict.update(method_fields)
        self.logger.debug(json.dumps(json_dict))
        return json.dumps(json_dict)