Git Product home page Git Product logo

json2delphirecord's Introduction

JSON2DelphiRecord

[FireMonkey] make records from json data

ERROR №1 (The array elements must be in the format {"key": value})
{
  "telephones": ["000000000", "111111111111"]
}

CORRECT

{
  "telephones": [{"key":"000000000"}, {"key":"111111111111"}]
}

ERROR №2 (the array should be named)
[{"index":3},{"index":4},{"index":2},{"index":1}]

CORRECT

{
  "data": [{"index":3},{"index":4},{"index":2},{"index":1}]
}
ERROR №3 (NULL not supported)
{
  "menu":  
  {
    "header":"xProgress SVG Viewer",
    "items":[
      {
        "id":"OpenNew",
        "label":"Open New"      
      },
      null,
      {
        "id":"ZoomIn",
        "label":"Zoom In"      
      }    
    ]  
  }
}

Correct

{
  "menu":  
  {
    "header":"xProgress SVG Viewer",
    "items":[
      {
        "id":"OpenNew",
        "label":"Open New"      
      },
      {
        "id":"ZoomIn",
        "label":"Zoom In"      
      }    
    ]  
  }
}

Simple Object

{
  "A": 1,
  "B": "2",
  "C": 1.3,
  "D": false,
  "F": "2014-05-03T03:25:05.059"
}

Output

TmyTypeRecord = record
  A: integer;
  B: string;
  C: float;
  D: boolean;
  F: string;
end;

Objects

{"widget": {
    "debug": "on",
    "window": {
        "title": "Sample Konfabulator Widget",
        "name": "main_window",
        "width": 500,
        "height": 500
    },
    "image": { 
        "src": "Images/Sun.png",
        "name": "sun1",
        "hOffset": 250,
        "vOffset": 250,
        "alignment": "center"
    },
    "text": {
        "data": "Click Here",
        "size": 36,
        "style": "bold",
        "name": "text1",
        "hOffset": 250,
        "vOffset": 100,
        "alignment": "center",
        "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
    }
}} 

Output

TmyTypeImage = record
  src: string;
  name: string;
  hOffset: integer;
  vOffset: integer;
  alignment: string;
end;

TmyTypeText = record
  data: string;
  size: integer;
  style: string;
  name: string;
  hOffset: integer;
  vOffset: integer;
  alignment: string;
  onMouseUp: string;
end;

TmyTypeWindow = record
  title: string;
  name: string;
  width: integer;
  height: integer;
end;

TmyTypeWidget = record
  debug: string;
  window: TmyTypeWindow;
  image: TmyTypeImage;
  text: TmyTypeText;
end;

TmyTypeRecord = record
  widget: TmyTypeWidget;
end;

Array

{"markers": [
		{
			"point": "new GLatLng(40.266044,-74.718479)",
			"homeTeam":"Lawrence Library",
			"awayTeam":"LUGip",
			"markerImage":"images/red.png",
			"information": "Linux users group meets second Wednesday of each month.",
			"fixture":"Wednesday 7pm",
			"capacity":"",
			"previousScore":""
		},
		{
			"point":"new GLatLng(40.211600,-74.695702)",
			"homeTeam":"Hamilton Library",
			"awayTeam":"LUGip HW SIG",
			"markerImage":"images/white.png",
			"information": "Linux users can meet the first Tuesday of the month to work out harward and configuration issues.",
			"fixture":"Tuesday 7pm",
			"capacity":"",
			"tv":""
		},
		{
			"point":"new GLatLng(40.294535,-74.682012)",
			"homeTeam":"Applebees",
			"awayTeam":"After LUPip Mtg Spot",
			"markerImage":"images/newcastle.png",
			"information": "Some of us go there after the main LUGip meeting, drink brews, and talk.",
			"fixture":"Wednesday whenever",
			"capacity":"2 to 4 pints",
			"tv":""
		}
] }

Output

TmyTypeMarkers = record
  point: string;
  homeTeam: string;
  awayTeam: string;
  markerImage: string;
  information: string;
  fixture: string;
  capacity: string;
  tv: string;
end;

TmyTypeRecord = record
  markers: TArray<TmyTypeMarkers>;
end;

json2delphirecord's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.