当前位置: 首页>>代码示例>>Java>>正文


Java JSONObject.put方法代码示例

本文整理汇总了Java中org.apache.tapestry5.json.JSONObject.put方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.put方法的具体用法?Java JSONObject.put怎么用?Java JSONObject.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tapestry5.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.put方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
@GET
@Path("/validate")
@PermitAll
public Response validate( @Context Request req)
{
    Subject subject;
    try {
        subject = securityService.getSubject();
        if (subject.isAuthenticated()) {
            return Response.ok().build();
        }
    }
    catch (Exception e) {
        LOG.debug("User failed to log.");
    }
    JSONObject JSONEntity = new JSONObject();
    JSONEntity.put("message","not Authenticated");
    return Response.status(Response.Status.BAD_REQUEST).entity(JSONEntity.toString()).build();
}
 
开发者ID:ffacon,项目名称:tapestry5-angular2-demo,代码行数:20,代码来源:UserService.java

示例2: postLogin

import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
@POST
@Path("/authentication")
@Consumes("application/x-www-form-urlencoded")
@PermitAll
public Response postLogin(@FormParam("j_username") String username,@FormParam("j_password") String password) {
    Response.ResponseBuilder rb;

    Subject subject;
    try {
        subject = securityService.getSubject();
        if (!subject.isAuthenticated()) {
            UsernamePasswordToken token = new UsernamePasswordToken(username, password);
            subject.login(token);
            token.clear();
            String userPassword= username + ":" + password;
            String basicAuth = new String(Base64.encodeBytes(userPassword.getBytes()));
            Token cltToken = new Token();
            cltToken.setAccess_token("Basic "+basicAuth);
            cltToken.setExpires_in(1799);
            cltToken.setToken_type("bearer");
            cltToken.setScope("read write");
            rb = Response.ok(cltToken);
            return rb.build();

        } else {
            LOG.debug("User [" + subject.getPrincipal() + "] already authenticated.");
            if(subject.getPrincipal().toString().equals(username))
            {
                rb = Response.ok();
                return rb.build();
            }
        }
    } catch (Exception e) {
        LOG.debug("User failed to log.");
    }
    JSONObject JSONEntity = new JSONObject();
    JSONEntity.put("message","invalid user or password");
    return Response.status(Response.Status.BAD_REQUEST).entity(JSONEntity.toString()).build();

}
 
开发者ID:ffacon,项目名称:tapestry5-angular2-demo,代码行数:41,代码来源:UserService.java

示例3: afterRender

import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
void afterRender(final MarkupWriter writer) {
  writer.end();
  JSONObject parameters = new JSONObject();
  for (String informalParameterName : componentResources.getInformalParameterNames()) {
    parameters.put(informalParameterName,
        componentResources.getInformalParameter(informalParameterName, Object.class));
  }
  javaScriptSupport.require("angular2/js/a2component").with(module, clientId, parameters);
}
 
开发者ID:ffacon,项目名称:tapestry5-angular2,代码行数:10,代码来源:A2Component.java

示例4: addApplicationConfigModule

import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
@Contribute(ModuleManager.class)
public static void addApplicationConfigModule(
    final MappedConfiguration<String, JavaScriptModuleConfiguration> configuration, final SymbolSource symbolSource,
    @Symbol(SymbolConstants.PRODUCTION_MODE) final boolean productionMode) {

  final JSONObject config = new JSONObject();

  for (String symbolName : new String[] { SymbolConstants.CONTEXT_PATH, SymbolConstants.EXECUTION_MODE,
      SymbolConstants.PRODUCTION_MODE, SymbolConstants.START_PAGE_NAME, SymbolConstants.TAPESTRY_VERSION,
      SymbolConstants.SUPPORTED_LOCALES }) {
    String value = symbolSource.valueForSymbol(symbolName);
    config.put(symbolName, value);
  }
  config.put("react-api-path", ReactAPIFilter.path);

  StringBuilder sb = new StringBuilder();
  sb.append("define(");
  sb.append(config.toString(productionMode));
  sb.append(");");
  final byte[] bytes = sb.toString().getBytes(StandardCharsets.UTF_8);

  configuration.add("eddyson/react/application-config", new JavaScriptModuleConfiguration(new VirtualResource() {

    @Override
    public InputStream openStream() throws IOException {
      return new ByteArrayInputStream(bytes);
    }

    @Override
    public String getFile() {
      return "application-config.js";
    }

    @Override
    public URL toURL() {
      return null;
    }
  }));

}
 
开发者ID:eddyson-de,项目名称:tapestry-react,代码行数:41,代码来源:ReactModule.java

示例5: afterRender

import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
void afterRender(final MarkupWriter writer) {
  writer.end();
  JSONObject parameters = new JSONObject();
  for (String informalParameterName : componentResources.getInformalParameterNames()) {
    parameters.put(informalParameterName,
        componentResources.getInformalParameter(informalParameterName, Object.class));
  }
  javaScriptSupport.require("eddyson/react/components/reactcomponent").with(module, clientId, parameters);
}
 
开发者ID:eddyson-de,项目名称:tapestry-react,代码行数:10,代码来源:ReactComponent.java

示例6: afterRender

import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
@AfterRender
public void afterRender() {

    // Tell the Tapestry.Initializer to do the initializing of a Confirm,
    // which it will do when the DOM has been
    // fully loaded.

    JSONObject spec = new JSONObject();
    spec.put("elementId", clientElement.getClientId());
    spec.put("message", message);
    javaScriptSupport.addInitializerCall("confirm", spec);
}
 
开发者ID:beargiles,项目名称:project-student,代码行数:13,代码来源:Confirm.java

示例7: afterRender

import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
@AfterRender
public void afterRender() {

	// Tell the Tapestry.Initializer to do the initializing of a Confirm, which
	// it will do when the DOM has been
	// fully loaded.

	JSONObject spec = new JSONObject();
	spec.put("elementId", clientElement.getClientId());
	spec.put("message", message);
	javaScriptSupport.addInitializerCall("confirm", spec);
}
 
开发者ID:onyxbits,项目名称:TradeTrax,代码行数:13,代码来源:Confirm.java

示例8: getSpecificOptions

import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
@Override
public JSONObject getSpecificOptions() {
	JSONObject res= new JSONObject();
	if (width!=null){
		res.put("width", width);
	}
	if (height!=null){
		res.put("height", height);
	}
	return res;
}
 
开发者ID:got5,项目名称:tapestry5-d3,代码行数:12,代码来源:DimpleGroupedBarChart.java

示例9: getData

import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
public JSONArray getData(){
	
	JSONObject o1= new JSONObject();
	o1.put("label", "one");
	o1.put("value", 20.0);
	JSONObject o2= new JSONObject();
	o2.put("label", "two");
	o2.put("value", 50.0);		
	JSONObject o3= new JSONObject();
	o3.put("label", "three");
	o3.put("value", 30.0);		
	
	return new JSONArray(o1, o2, o3);
}
 
开发者ID:got5,项目名称:tapestry5-d3,代码行数:15,代码来源:PieChartPage.java

示例10: getParams

import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
public JSONObject getParams(){
	JSONObject json =  new JSONObject();
	json.put("active_class", "open");// specify the class used for active sections
	json.put("is_hover",false);
       return json;
}
 
开发者ID:ffacon,项目名称:tapestry5-angular2,代码行数:7,代码来源:HelloWorld_Typescript.java

示例11: onSuccess

import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
public Object onSuccess() {
    if (genConfig) {
        JSONObject cfg = new JSONObject();
        
        // all default values            
        cfg.put("useRecordingSyncMap", "false");
        cfg.put("developer_mode", "false");
        cfg.put("svdrpPort", "5000");
        cfg.put("remoteOsdSleepTime", "200");
        cfg.put("remoteOsdIncSleepTime", "200");
        cfg.put("useEpgd", String.valueOf(setup.isUseEpgd()));
        cfg.put("epgVdr", setup.getEpgVdr());
        
        // hsqldb configuration
        JSONObject hsql = new JSONObject();
        hsql.put("path", "/var/cache/jonglisto-db");
        hsql.put("remote", "false");            
        cfg.put("hsqldb", hsql);

        // nashorn scripts
        JSONObject nashorn = new JSONObject();
        nashorn.put("svdrp", "/etc/jonglisto/svdrp.js");
        nashorn.put("epg2vdr", "/etc/jonglisto/epg2vdr.js");
        cfg.put("NashornScripts", nashorn);

        // mysql configuration
        JSONObject mysql = new JSONObject();
        mysql.put("url", "jdbc:mysql://" + setup.getEpgdHost() + ":" + setup.getEpgdPort() + "/" + setup.getEpgdDatabase());
        mysql.put("username", setup.getEpgdUser());
        mysql.put("password", setup.getEpgdPassword());
        cfg.put("epg2vdr", mysql);

        // aliases            
        JSONObject aliases = new JSONObject();
        setup.getAvailableVdr().stream() //
            .forEach(s -> {
                aliases.put(s.getAlias(), s.getUuid());
            });
        cfg.put("aliases", aliases);
        
        // VDR
        setup.getAvailableVdr().stream() //
            .forEach(s -> {
                JSONObject vdrcfg = new JSONObject();
                vdrcfg.put("uuid", s.getAlias());
                vdrcfg.put("displayName", s.getDisplayName());
                
                JSONObject vdrval = new JSONObject();
                vdrval.put("TIMER_AUX", "");
                vdrval.put("TIMER_MINUS_MINUTES", 10);
                vdrval.put("TIMER_PLUS_MINUTES", 10);
                vdrval.put("TIMER_PRIORITY", 50);
                vdrval.put("TIMER_LIFETIME", 99);
                vdrval.put("RECORDING_NAMING_MODE", 1);
                vdrcfg.put("config", vdrval);
                
                cfg.append("VDR", vdrcfg);
            });
        
        // Sichten
        setup.getAvailableViews().stream() //
            .forEach(s -> {
                JSONObject sicht = new JSONObject();
                sicht.put("displayName", s.getName());
                sicht.put("head", s.getHead().get(0));
                sicht.put("timers", s.getTimer().get(0));
                s.getChannels().stream().forEach(c -> sicht.append("channels", c));
                s.getRecordings().stream().forEach(r -> sicht.append("recordings", r));
                
                cfg.append("Sichten", sicht);
            });
        
        streamResponse.setStreamContent(cfg.toString(false));
        streamResponse.setStreamFilename("jonglisto.json");
        streamResponse.setStreamType("text/plain");
        
        return streamResponse;
    } else {
        return null;
    }        
}
 
开发者ID:Zabrimus,项目名称:vdr-jonglisto,代码行数:82,代码来源:Setup.java


注:本文中的org.apache.tapestry5.json.JSONObject.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。