• Modules
    • By category
    • By name
    • Most popular
    • Most downloaded
    • Repository
  • Register
  • Log in
  • Help
    • Start using Ceylon Herd
    • Publish your first module
    • Module publishing guidelines
    • All about Ceylon
    • Keyboard Shortcuts

    • s Focus search module bar
      ? Open this information panel
      j Move selection down
      k Move selection up
      enter Open current selection
Module info
Name
FroMage / ceylon.json / 1.0.1
Ceylon JSON Platform Module
Category SDK

The Ceylon SDK

Backends JVM JavaScript
Maven coordinates
Compatible Ceylon release JVM: 1.0.0 (outdated)
JavaScript: 1.0.0 (outdated)
Published Nov 27, 2013
Stats Downloads (JVM): 620
Downloads (JS): 301
Source downloads: 690
Authors Stéphane Épardaud
License Apache Software License
Description

Contains everything required to parse and serialise JSON data.

Sample usage for parsing and accessing JSON:

String getAuthor(String json){
    value parsedJson = parse(json);
    if(is String author = parsedJson.get("author")){
        return author;
    }
    throw Exception("Invalid JSON data");
}

Or if you're really sure that you should have a String value:

String getAuthor(String json){
    value parsedJson = parse(json);
    return parsedJson.getString("author")){
}

You can iterate Json objects too::

{String*} getModules(String json){
    value parsedJson = parse(json);
    if(is Array modules = parsedJson.get("modules")){
        return { for (mod in modules) 
                   if(is Object mod, is String name = mod.get("name")) 
                     name 
               };
    }
    throw Exception("Invalid JSON data");
}     

Sample usage for generating JSON data:

String getJSON(){
    value json = Object {
        "name" -> "Introduction to Ceylon",
        "authors" -> Array {
            "Stef Epardaud",
            "Emmanuel Bernard"
        }
    };
    return json.string;
}
Dependencies
ceylon.collection/1.0.0 shared
Usage
  • Import
 import ceylon.json "1.0.1";
Module links Members
Imported By
Home
Code repository
Issue tracker
Browse
Download .car
Download .js
Download source archive
Download module documentation
View API documentation

Ceylon Herd v1.24 Copyright 2012-2021 Red Hat. About