This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person { | |
private String name; | |
private String city; | |
private int age; | |
private String[] nickNames; | |
public String getName() { | |
return name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PersonSerialize { | |
public static void main(String[] args) throws Exception{ | |
JsonSerializer jsonSerializer = JsonSerializer.DEFAULT_READABLE; | |
String[] nickNames = {"Jil", "Bil", "Rock"}; | |
Person pojo = new Person("Jackson", "Colombo", 24, nickNames); | |
String json = jsonSerializer.serialize(pojo); | |
System.out.println(json); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PersonSerialize { | |
public static void main(String[] args) throws Exception{ | |
XmlSerializer xmlSerializer = XmlSerializer.DEFAULT_SQ_READABLE; | |
String[] nickNames = {"Jil", "Bil", "Rock"}; | |
Person pojo = new Person("Jackson", "Colombo", 24, nickNames); | |
String xml = xmlSerializer.serialize(pojo); | |
System.out.println(xml); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PersonDeserialize { | |
public static void main(String[] args) throws Exception{ | |
JsonParser jsonParser = JsonParser.DEFAULT; | |
String json = "{\"name\":\"Jackson\",\"age\":24,\"nickNames\":[\"Jil\",\"Bil\",\"Rock\"],\"city\":\"Colombo\"}"; | |
Person p = jsonParser.parse(json, Person.class); | |
System.out.println(Arrays.toString(p.getNickNames())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = raw_input() | |
print "Hello %s!" % name | |
# Simply prints Hello <name>! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function printNumbers() | |
for i in 1 to 10 | |
print i | |
printNumbers() // call printNumbers() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mycompany.rhinojsexample; | |
import com.mycompany.rhinojsexample.hostobjects.ConsoleRunner; | |
import org.mozilla.javascript.Context; | |
import org.mozilla.javascript.Scriptable; | |
import org.mozilla.javascript.ScriptableObject; | |
public class RhinoExample { | |
public static void main(String[] args) { | |
String code = "var a=[2,8,5]; a[1] + a[0];"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mycompany.rhinojsexample.hostobjects; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import org.mozilla.javascript.ScriptableObject; | |
public class ConsoleRunner extends ScriptableObject { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mycompany.rhinojsexample; | |
import com.mycompany.rhinojsexample.hostobjects.ConsoleRunner; | |
import org.mozilla.javascript.Context; | |
import org.mozilla.javascript.Scriptable; | |
import org.mozilla.javascript.ScriptableObject; | |
public class RhinoExample { | |
public static void main(String[] args) { | |
String code = "var cr = new ConsoleRunner();" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let getData = (url) => { | |
return new Promise((resolve, reject) => { | |
let data = {items: [{id: parseInt(Math.random() * 100000)}, | |
{id: parseInt(Math.random() * 100000)}]}; | |
console.log(1); | |
if(data.items[0].id % 4 != 0) | |
data.nextPage = url; | |
resolve(data); | |
}); |
OlderNewer