associate a raw JSON form to the current thread<br>

@since Twitter4J 2.1.7
510604
static <T> T registerJSONObject(T key, Object json) {
        registeredAtleastOnce = true;
        rawJsonMap.get().put(key, json);
        return key;
    }
1221810
public static Place createPlace(String rawJSON) throws TwitterException {
        try {
            return new PlaceJSONImpl(new JSONObject(rawJSON));
        } catch (JSONException e) {
            throw new TwitterException(e);
        }
    }
28653
private Object getEmbeddedObject(JsonParser jsonParser) throws IOException {
        LOG.info("Start parsing an embedded object.");
        Map<String, Object> embeddedMap = new HashMap<>();
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String key = jsonParser.getText();
            jsonParser.nextToken();
            JsonToken token = jsonParser.getCurrentToken();
            if (token == JsonToken.START_ARRAY) {
                Object embeddedArray = getCollectionValue(jsonParser);
                embeddedMap.put(key, embeddedArray);
            } else if (token == JsonToken.START_OBJECT) {
                Object embeddedObject = getEmbeddedObject(jsonParser);
                embeddedMap.put(key, embeddedObject);
            } else {
                if (token.equals(JsonToken.VALUE_NULL)) {
                    embeddedMap.put(key, null);
                } else {
                    embeddedMap.put(key, jsonParser.getText());
                }
            }
        }
        return embeddedMap;
    }
789652
public static User createUser(String rawJSON) throws TwitterException {
        try {
            return new UserJSONImpl(new JSONObject(rawJSON));
        } catch (JSONException e) {
            throw new TwitterException(e);
        }
    }
852487
private Object currentValue() throws JsonParserException {
    // Only a value start token should appear when we're in the context of parsing a JSON value
    if (token.isValue)
      return value;
    throw createParseException(null, "Expected JSON value, got " + token, true);
  }
392258
def update(self, **kwargs):
        

        old_json = self.__json__()

        for prop in kwargs:
            setattr(self, prop, kwargs[prop])

        # We send notif only if object has changed
        if old_json != self.__json__():
            self.controller.notification.emit("project.updated", self.__json__())
            self.dump()
278285
@Override
	protected MappingJackson2HttpMessageConverter getJsonMessageConverter() {
		MappingJackson2HttpMessageConverter converter = super.getJsonMessageConverter();
		converter.setObjectMapper(new ObjectMapper().registerModule(new TwitterModule()));		
		return converter;
	}
472678
def write_json(self, **kwargs):
        
        self.stdout.write(json.dumps(kwargs) + "\n")
        self.stdout.flush()
312003
@Override
  public void setup(JavaStreamingContext jssc, CommandLine cli) throws Exception {
    String filtersArg = cli.getOptionValue("tweetFilters");
    String[] filters = (filtersArg != null) ? filtersArg.split(",") : new String[0];

    // start receiving a stream of tweets ...
    JavaReceiverInputDStream<Status> tweets =
      TwitterUtils.createStream(jssc, null, filters);

    String fusionUrl = cli.getOptionValue("fusion");
    if (fusionUrl != null) {
      // just send JSON directly to Fusion
      SolrSupport.sendDStreamOfDocsToFusion(fusionUrl, cli.getOptionValue("fusionCredentials"), tweets.dstream(), batchSize);
    } else {
      // map incoming tweets into PipelineDocument objects for indexing in Solr
      JavaDStream<SolrInputDocument> docs = tweets.map(
          new Function<Status,SolrInputDocument>() {

            /**
             * Convert a twitter4j Status object into a SolrJ SolrInputDocument
             */
            public SolrInputDocument call(Status status) {

              if (log.isDebugEnabled()) {
                log.debug("Received tweet: " + status.getId() + ": " + status.getText().replaceAll("\\s+", " "));
              }

              // simple mapping from primitives to dynamic Solr fields using reflection
              SolrInputDocument doc =
                  SolrSupport.autoMapToSolrInputDoc("tweet-"+status.getId(), status, null);
              doc.setField("provider_s", "twitter");
              doc.setField("author_s", status.getUser().getScreenName());
              doc.setField("type_s", status.isRetweet() ? "echo" : "post");

              if (log.isDebugEnabled())
                log.debug("Transformed document: " + doc.toString());
              return doc;
            }
          }
      );

      // when ready, send the docs into a SolrCloud cluster
      SolrSupport.indexDStreamOfDocs(zkHost, collection, batchSize, docs.dstream());
    }
  }
224852
private static String getJsonFromRaw(Context context, int resource) {
        String json;
        try {
            InputStream inputStream = context.getResources().openRawResource(resource);
            int size = inputStream.available();
            byte[] buffer = new byte[size];
            inputStream.read(buffer);
            inputStream.close();
            json = new String(buffer, "UTF-8");
        } catch (IOException ex) {
            ex.printStackTrace();
            return null;
        }
        return json;
    }
517795
function(params, callback) {
                var updateThreadInfoData = {
                    chatMessageVOType: chatMessageVOTypes.UPDATE_THREAD_INFO,
                    typeCode: params.typeCode,
                    subjectId: params.threadId,
                    content: {},
                    pushMsgType: 4,
                    token: token
                };

                if (params) {
                    if (parseInt(params.threadId) > 0) {
                        updateThreadInfoData.subjectId = params.threadId;
                    }
                    else {
                        fireEvent('error', {
                            code: 999,
                            message: 'Thread ID is required for Updating thread info!'
                        });
                    }

                    if (typeof params.image == 'string') {
                        updateThreadInfoData.content.image = params.image;
                    }

                    if (typeof params.description == 'string') {
                        updateThreadInfoData.content.description = params.description;
                    }

                    if (typeof params.title == 'string') {
                        updateThreadInfoData.content.name = params.title;
                    }

                    if (typeof params.metadata == 'object') {
                        updateThreadInfoData.content.metadata = JSON.stringify(params.metadata);
                    }
                    else if (typeof params.metadata == 'string') {
                        updateThreadInfoData.content.metadata = params.metadata;
                    }
                }

                return sendMessage(updateThreadInfoData, {
                    onResult: function(result) {
                        callback && callback(result);
                    }
                });
            }
184936
public static Location createLocation(String rawJSON) throws TwitterException {
        try {
            return new LocationJSONImpl(new JSONObject(rawJSON));
        } catch (JSONException e) {
            throw new TwitterException(e);
        }
    }
678342
function pprintJSON(formJson, opts, indentLevel, priorNodeStr) {
  opts = opts || {};
  opts.spaces = opts.spaces || 2;
  opts.lbracket = opts.lbracket || "[";
  opts.rbracket = opts.rbracket || "]";
  opts.separator = opts.separator || ", ";
  indentLevel = indentLevel || 0;
  var nl = opts.oneLine ? " " : "\n";
  var str = ""

  function indentToSpaces(indentLevel) {
    return(!opts.omitTop ? indentLevel * opts.spaces : (indentLevel - 1) * opts.spaces);
  }

  if(Array.isArray(formJson)) {
    var numSpaces = indentToSpaces(indentLevel);
    if(!(opts.omitTop && indentLevel === 0)) {
      // I added these last two checks below specifically for formatting html tags
      // (the length check might adversely effect formatting normal code not sure yet )
      if((priorNodeStr !== '"function"' && priorNodeStr !== 'function') &&
          formJson.length > 0 && formJson[0] !== "attr") {
        str += (priorNodeStr ? nl : "") // omit the unecessary *first* "\n"
        str += (priorNodeStr && numSpaces > 0 ? " ".repeat(numSpaces) : "")
      }
      str += opts.lbracket
    }

    if(formJson[0] === "object" || formJson[0] === "attr") {
      if(opts.attrsAsJson || opts.objectsAsJson) {
        // pretty print the key/value pairs of an object/attr as a js object:
        str += "{";
        for(var i=1; i<formJson.length;i+=2) {
          if(i === 1) { str += nl; }
          var propNameStr = pprintJSON(formJson[i], opts);
          propNameStr = ((propNameStr.indexOf("-") !== -1) ? '"' + propNameStr + '"' : propNameStr);
          str += (numSpaces+1 > 0 ? " ".repeat(indentToSpaces(indentLevel+1)) : "") +
                  propNameStr + ": " +
                  pprintJSON(formJson[i+1], opts, indentLevel + 2, formJson[i]) + (i+2 < formJson.length ? opts.separator : "") + nl;
        }
        str += "}";
      }
      else {
        // pretty print the key/value pairs of an object/attr as an s-expr list
        str += pprintJSON(formJson[0], opts) + opts.separator + nl;
        for(var i=1; i<formJson.length;i+=2) {
          str += (numSpaces+1 > 0 ? " ".repeat(indentToSpaces(indentLevel+1)) : "") +
                 pprintJSON(formJson[i], opts) + opts.separator +
                 pprintJSON(formJson[i+1], opts, indentLevel + 2, formJson[i]) + (i+2 < formJson.length ? opts.separator : "") + nl;
        }
      }
    }
    else {
      // pretty print the body of a normal list
      var priorNodeStr;
      formJson.forEach(function(node, i) {
        priorNodeStr = pprintJSON(node, opts, indentLevel + 1, priorNodeStr)
        str += priorNodeStr
        if(i < formJson.length - 1) {
          str += opts.separator
        }
      })
    }
    if(!(opts.omitTop && indentLevel === 0)) {
      str += opts.rbracket
    }
  }
  else if(formJson == null) {
    str += "null";
  }
  else if(typeof formJson === 'string' && !opts.bareSymbols) {
    // I had backslashed single quotes below -
    // but jsonlint rejected so I don't...
    str += ('"' + formJson.replace(/[\\"]/g, '\\$&') + '"')
  }
  else if(formJson.toString) {
    str += formJson.toString();
  }
  else {
    throw new Error('Unknown form type in pprintJSON: ' + formJson + ' (' + typeof formJson + ')');
  }
  return str
}
800428
def save_model(self, request, obj, form, change):
        
        super(TweetableAdminMixin, self).save_model(request, obj, form, change)
        if Api and request.POST.get("send_tweet", False):
            auth_settings = get_auth_settings()
            obj.set_short_url()
            message = truncatechars(obj, 140 - len(obj.short_url) - 1)
            api = Api(*auth_settings)
            api.PostUpdate("%s %s" % (message, obj.short_url))
255572
public void toJson(JsonElement jsonElement, JsonWriter writer) throws JsonIOException {
    boolean oldLenient = writer.isLenient();
    writer.setLenient(true);
    boolean oldHtmlSafe = writer.isHtmlSafe();
    writer.setHtmlSafe(htmlSafe);
    boolean oldSerializeNulls = writer.getSerializeNulls();
    writer.setSerializeNulls(serializeNulls);
    try {
      Streams.write(jsonElement, writer);
    } catch (IOException e) {
      throw new JsonIOException(e);
    } catch (AssertionError e) {
      AssertionError error = new AssertionError("AssertionError (GSON " + GsonBuildConfig.VERSION + "): " + e.getMessage());
      error.initCause(e);
      throw error;
    } finally {
      writer.setLenient(oldLenient);
      writer.setHtmlSafe(oldHtmlSafe);
      writer.setSerializeNulls(oldSerializeNulls);
    }
  }
1037157
function _bindReadable(pointer, stream, serializer) {
  stream.on('data', (data) => {
    serializer.write(jsonrpc.notification(pointer, [data]));
  });
  stream.on('end', () => {
    serializer.write(jsonrpc.notification(pointer, [null]));
  });
  stream.on('error', () => {
    serializer.write(jsonrpc.notification(pointer, [null]));
  });
}
1342574
def thread_view(request, pk):
    '''  '''
    if request.is_ajax():
        if not request.user.is_authenticated():
            return HttpResponse(json.dumps(dict()),
                                content_type="application/json")
        try:
            user_profile = UserProfile.objects.get(user=request.user)
        except UserProfile.DoesNotExist:
            return HttpResponse(json.dumps(dict()),
                                content_type="application/json")
        try:
            thread = Thread.objects.get(pk=pk)
        except Thread.DoesNotExist:
            return HttpResponse(json.dumps(dict()),
                                content_type="application/json")
        follow_form = FollowThreadForm(
            request.POST if "follow_thread" in request.POST else None,
            instance=thread,
            profile=user_profile,
        )
        if follow_form.is_valid():
            following = follow_form.save()
            response = dict(
                following=following,
                num_of_followers=thread.followers.all().count()
            )
            return HttpResponse(json.dumps(response),
                                content_type="application/json")
        raise Http404
    userProfile = UserProfile.objects.get(user=request.user)
    thread = get_object_or_404(Thread, pk=pk)
    messages_list = Message.objects.filter(thread=thread)

    follow_form = FollowThreadForm(
        request.POST if "follow_thread" in request.POST else None,
        instance=thread,
        profile=userProfile,
        )

    if follow_form.is_valid():
        following = follow_form.save()
        if following:
            message = "You are now following this thread."
        else:
            message = "You are no longer following this thread."
        messages.add_message(request, messages.INFO, message)
        return HttpResponseRedirect(reverse("threads:view_thread",
                                            kwargs={"pk": pk}))

    edit_forms, delete_forms = [], []

    for message in messages_list:
        edit_message_form, delete_message_form = None, None
        if message.owner == userProfile or userProfile.user.is_superuser:
            edit_message_form = EditMessageForm(
                request.POST if "edit_message-{0}".format(message.pk) in request.POST else None,
                instance=message,
                prefix="edit-{0}".format(message.pk),
                )
            delete_message_form = DeleteMessageForm(
                request.POST if "delete_message-{0}".format(message.pk) in request.POST else None,
                instance=message,
                )
            if edit_message_form.is_valid():
                edit_message_form.save()
                messages.add_message(request, messages.INFO, "Message updated.")
                return HttpResponseRedirect(reverse("threads:view_thread", kwargs={
                    "pk": pk,
                    }))
            if delete_message_form.is_valid():
                thread = delete_message_form.save()
                messages.add_message(request, messages.INFO, "Message deleted.")
                if thread is None:
                    return HttpResponseRedirect(reverse("threads:list_all_threads"))
                return HttpResponseRedirect(reverse("threads:view_thread", kwargs={
                    "pk": thread.pk,
                    }))

        edit_forms.append(edit_message_form)
        delete_forms.append(delete_message_form)

    edit_thread_form = None
    if thread.owner == userProfile or request.user.is_superuser:
        edit_thread_form = EditThreadForm(
            request.POST if "edit_thread" in request.POST else None,
            instance=thread,
            )

    add_message_form = MessageForm(
        request.POST if "add_message" in request.POST else None,
        profile=userProfile,
        thread=thread,
        )

    if edit_thread_form and edit_thread_form.is_valid():
        thread = edit_thread_form.save()
        return HttpResponseRedirect(reverse("threads:view_thread", kwargs={
            "pk": thread.pk,
            }))
    elif add_message_form.is_valid():
        add_message_form.save()
        return HttpResponseRedirect(reverse('threads:view_thread', kwargs={
            'pk': pk,
            }))
    elif request.method == "POST":
        messages.add_message(request, messages.ERROR, MESSAGES['MESSAGE_ERROR'])


    thread.views += 1
    thread.save()

    following = request.user in thread.followers.all()

    return render_to_response('view_thread.html', {
        'thread': thread,
        'page_name': thread.subject,
        'messages_list': zip(messages_list, edit_forms, delete_forms),
        "add_message_form": add_message_form,
        "edit_thread_form": edit_thread_form,
        "following": following,
        "follow_form": follow_form,
        }, context_instance=RequestContext(request))