Send JSON representation of a data object to all connections of a certain user

@param data the data to be sent
@param username the username
@return this context
546103
public WebSocketContext sendJsonToUser(Object data, String username) {
        return sendToTagged(JSON.toJSONString(data), username);
    }
1161383
public Object setUserData(String key, Object data, UserDataHandler handler) {
	// dynamic load to support jre 1.4 and 1.5
	try {
	    Method m = node.getClass().getMethod("setUserData", new Class[] { key.getClass(), data.getClass(), handler.getClass() });
	    return m.invoke(node, new Object[] { key, data, handler });
	}
	catch (Exception e) {
	    throw new PageRuntimeException(Caster.toPageException(e));
	}
    }
922291
public static String exportDictionary(String name, String data) {

        StringBuffer sb = new StringBuffer();
        sb.append("<meta name=\"").append(name).append("\" content=\"").append(data).append("\" />");
        return sb.toString();
    }
854329
public void send(String data, EventCallback callback) {
        send(data, null, null, callback);
    }
889350
public UserBuilder withData(String name, Object value) {
        if (this.data == null) {
            this.data = new HashMap<>();
        }

        this.data.put(name, value);
        return this;
    }
596407
public function withJsonBody($data, SerializationContext $context = null)
    {
        if (is_string($data)) {
            $json = $data;
        } else {
            $json = SerializerBuilder::create()->build()->serialize($data, 'json', $context);
        }
        $this->withBody($json);

        return $this;
    }
980953
public void setThisData(byte[] data)
    {
        try
        {
            pen.setData(data);
        }
        catch ( Exception e )
        {
            ThreadUtils.checkInterrupted(e);
            Throwables.propagate(e);
        }
    }
777338
public void setData(byte[] data) {
        byte[] copy = new byte[data.length];
        System.arraycopy(data, 0, copy, 0, data.length);
        this.data = copy;
    }
95649
@SuppressWarnings({ "squid:S1166" })
    private static UserDetails loadUserByUsername(final String username) {
        final UserDetailsService userDetailsService = SpringContextHelper.getBean(UserDetailsService.class);
        try {
            return userDetailsService.loadUserByUsername(username);
        } catch (final UsernameNotFoundException e) {
            return new User(username, "", Collections.emptyList());
        }
    }
238343
public WebSocketContext sendToUser(String message, String username) {
        return sendToConnections(message, username, manager.usernameRegistry(), true);
    }
160430
@Benchmark
  @BenchmarkMode(Mode.SampleTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public byte[] toBinarySpanContext(Data data) {
    return data.binaryFormat.toByteArray(data.spanContext);
  }
575522
def send(self, data):
        
        self.logger.debug('Send data: {}'.format(data))

        if not self.connected:
            self.logger.warning('Connection not established. Return...')
            return

        self.websocket.send(json.dumps(data))
199157
def put_json(self, uri, data, **kwargs):
        
        encoded_data = json.dumps(data)
        kwargs.setdefault("headers", {}).update({
            "Content-Type": "application/json",  # tell server we are sending json
        })
        return self.put(uri, data=encoded_data, **kwargs)
948234
protected void addHttpData(InterfaceHttpData data) {
        if (data == null) {
            return;
        }
        List<InterfaceHttpData> datas = bodyMapHttpData.get(data.getName());
        if (datas == null) {
            datas = new ArrayList<InterfaceHttpData>(1);
            bodyMapHttpData.put(data.getName(), datas);
        }
        datas.add(data);
        bodyListHttpData.add(data);
    }
859318
public MessageIDEnvelope sendActions(Actions data) throws ApiException {
        ApiResponse<MessageIDEnvelope> resp = sendActionsWithHttpInfo(data);
        return resp.getData();
    }
51230
public static JsonNode toJson(final Object data) {
        if (data == null) {
            return newObject();
        }

        try {
            return createObjectMapper().valueToTree(data);
        } catch (Exception e) {
            throw new ParseException(e);
        }
    }
237520
def json_data(self, name):
        

        # Check the write permission of the context
        # XXX: This should be done on field level by the field manager adapter
        if not self.can_write():
            raise Unauthorized("You are not allowed to modify this content")

        # fetch the field by name
        field = api.get_field(self.context, name)

        # bail out if we have no field
        if not field:
            return None

        fieldmanager = IFieldManager(field)
        return fieldmanager.json_data(self.context)